Questions tagged [python-3.x]
Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 3 interpreter only. Do not mix this tag with the python-2.x tag.
4,453
questions
4
votes
1answer
58 views
Forecasts for construction equipment dealers
I was wondering if it is possible to speed up this script? The source file has 90,000 rows, and it has to create a separate forecast for 1200 unique dealers using fbprophet. I'm new to python so I'm ...
3
votes
1answer
57 views
Google Foobar Level 1 - Minion Task Schedule
I recently just stumbled upon a post regarding Google Foobar Level 2 and decided to try it out myself but starting from Level 1. The description and code are shown below.
Write a function called <...
4
votes
2answers
124 views
Generate prime factorisations of factorial numbers
The code was written to generate the factorisation of numbers into primes in ascending order. E.g 3! ='2 * 3', 4!='2^3 * 3'. When I have huge numbers such as 100!, the run time becomes a problem. I ...
1
vote
1answer
65 views
Calling different class objects using python
Im trying to get more grip of Classes and also calling different classes to each other which will be more understandable when showing code before:
Utils.py
...
5
votes
2answers
406 views
Higher or Lower guessing game
After an extended absence from coding, I decided I would make something to try and get back on my feet again. I ended up making a project that I have made several times before, a higher-lower guessing ...
1
vote
2answers
119 views
Google foobar level 2 challenge
I am a beginner in Python-3. I was solving a level 2 challenge in Google Foobar. Given an initial amount of items (LAMBs) I have to distribute it among individuals, who are ranked according to ...
4
votes
1answer
46 views
Tennis simulation
I am new to Python and coding in general, and I would like feedback on this program that I wrote. It simulates a tennis game, based on a players "serv chance" (how likely it is that a player ...
2
votes
1answer
34 views
Bulk slack emoji downloader
NOTE
The script relies on ruamel-yaml and requests packages
available on pypi.
I wrote a script which goes over the pack file details as specified by the emojipacks project, and downloads (and saves) ...
4
votes
1answer
68 views
Snake using Pygame
I'd be grateful if you could review my code. Please be as critical towards it as possible and yet indulgent when it comes to asking my first question here.
This is a simple snake game using pygame. I ...
6
votes
1answer
352 views
Capitalizing the first letter of every word in a string (with arbitrary spacing)
I solved the following question
You are asked to ensure that the first and last names of people begin
with a capital letter in their passports. For example, alison heck
should be capitalised ...
8
votes
2answers
935 views
Fibonacci sequence output
Here's the code I'm having trouble shortening. I am currently a beginner in Python 3.x.
...
4
votes
1answer
71 views
Reddit bot in Python
I have created a Reddit bot that goes through an "x" amount of posts. For each post it pulls all the comments from that post into a list then a data frame and then it loops over a CSV look ...
-4
votes
1answer
49 views
How can I reduce the TIme Complexity. of the python program
I have 7000 CSV files that I want to do operation on. but the problem is that it takes to much time like it takes 13 seconds to process these files.
What I need to know is which operation take more ...
4
votes
0answers
95 views
Optimizing recursive backtrack search algorithm in Skyscraper puzzle
I'm trying to solve a skyscraper puzzle for 6x6 boards using constraint programming and then backtracking. My solution works but is too slow, for certain cases, it takes up to 2 seconds and I was ...
5
votes
1answer
76 views
Getting death row inmates' last statement
Initial version of the code appeared as an answer to an SO question. I refactored the code a bit and it works pretty well, IMHO. I get a solid .csv file with all ...
6
votes
2answers
102 views
Chess Dictionary Validator from Automatic Boring Stuff with Python
This project is in chapter 5 introduced me to a whole new world of dictionary data structure. To put it briefly, I want to know whether the choice I took between lists, tuples, and dictionaries could'...
1
vote
2answers
64 views
Python script to extract columns from a CSV file
I have a very basic python script that reads a CSV file. I'm importing the csv module setting some empty list variables and getting the data I want. The problem is that I know there is a much more ...
3
votes
2answers
62 views
Creating some Loaded Dice to make our board game fairer
Some friends and I were playing a board game and decided that the random dice rolls just weren't fair! So we came up with a scheme for making the rolls slightly more evenly distributed, and I ...
4
votes
2answers
473 views
Chess game object-oriented
This is an object-oriented Chess game. So far, I have implemented the pawn and board functionalities and I would love to get a ...
6
votes
2answers
433 views
Coin Flip Streak from Automate the Boring Stuff with Python
I apologize beforehand if the question has been repeated so many times. This is a practice task from Automate the Boring Stuff with Python. In brief, the task entails writing a code that carries out ...
20
votes
4answers
2k views
Add 'ing' or 'ly' suffix to a string
I have been practising Python Practice questions and came across this question:
Write a Python program to add 'ing' at the end of a given string
(length should be at least 3).
If the given string ...
6
votes
1answer
47 views
Programmatically using `exec` to load files
I'm making a command line interface (CLI) role playing tool that tracks the state of the world, storing characters, monsters, etc as text files so their data can be edited directly if needed (free Vim ...
6
votes
1answer
211 views
“join” two list of dictionaries on Id
I have two lists of dictionaries where both have the same "id" key but otherwise different data.
...
5
votes
3answers
93 views
Hackerrank: Count the number of palindromes in a given string
I am solving a problem for Hackerrank where I have to count the number of palindromes in a given string.
I have the following code which counts the number of palindromes accurately but times out for ...
4
votes
1answer
38 views
SHA256 password cracker - v2 with concurrency
I have updated my previous code with the suggestions. I have also implemented concurrency to speed up the results.
I'd be interested for comments on a more efficient use on concurrency / parallel ...
5
votes
1answer
77 views
Bounded spigot algorithms for e and pi in Python
I've written bounded spigot algorithms(Spigot Algorithm) for e and pi. I would like to understand if there is anything I can do to make this more efficient. I've done things already like move the ...
3
votes
1answer
83 views
Counting maximum number of elements in right order
There is an source and target.
example:
source:[a,b,e,d,s,t,c,v,t]
target:[a,e,v,g,r,b,c,v,t]
target and source have same number of elements.
how can I count elements in source ordered correctly ...
6
votes
1answer
62 views
Python - Game stat calculator
So this is the code to a calculator I made for a game. Essentially what the calculator does is, it calculates the cost of buying the next stat.
So I wrote the code just for the Human race and the ...
26
votes
2answers
5k views
Printing 1,000,000 numbers in 1 sec. in Python
Here's a fairly simple task from CSES Problem Set - Permutations 1070 that reads:
A permutation of integers 1,2, …, n is called beautiful if there are no adjacent elements whose difference is 1.
...
2
votes
1answer
40 views
Summing Sequence with Combinatorics
I am looking for help for two things.
proof of correctness (the tests have passed, but I do not now how to prove it correct)
Improvements on the Algorithm Efficiency.
The algorithm goes through 2 ...
3
votes
2answers
63 views
LeetCode 8: String to Integer (atoi)
I'm posting a solution for LeetCode's "String to Integer (atoi)". If you'd like to review, please do. Thank you!
Problem
Implement atoi which converts a string to an integer. The function ...
2
votes
0answers
33 views
Gradient descent algorithm for solving localization problem in 3-dimensional space
Task
This code accomplishes the Time Difference of Arrival (TDoA) multilateration problem (see) using gradient descent (known otherwise as steepest descent).
Goal
I'm looking to:
a) Improve speed:
In ...
2
votes
0answers
28 views
Cave explorer: using stack
Story
Original Link written in korean
Frodo, a backcountry explorer, came to explore an underground cave with n rooms during his expedition. All rooms are numbered 0 through n-1. There are many, the ...
5
votes
2answers
74 views
Line protocol point generator
I made this little tool for something I was trying to accomplish at work. It works as intended but a personal goal of mine is to improve my code design so it's more simple, readable, and contributable....
4
votes
0answers
47 views
Finding cheapest route (turn costs 500, going straight costs 100)
Story
Original link written in korean
Jordi, the architect of a construction company, received a request from a customer for an estimate for the construction of a raceway.
According to the raceway ...
2
votes
1answer
46 views
Generate simple sinusoidal sounds and plot signal/fft
I made a small python script to create an audio sound used as stimuli. It's one of my first uses of super(), and I do not know if I did it right. I'm looking for ...
5
votes
1answer
74 views
This is Crossing river code
Story
Niñez friends from Kakao Elementary School meet a stream with stepping stones on an autumn picnic with Ms. Ryan and are about to cross over to the other side. Ms. Ryan made the following rules ...
3
votes
0answers
52 views
Graph: A backcountry explorer
Would you help me? I want to make this code efficient and simple.
Original Link
Frodo, a backcountry explorer, came to explore an underground cave with n rooms during his expedition. All rooms are ...
12
votes
4answers
2k views
TicTacToe in Python OOP
I did this Tic-Tac-Toe as an exercise for OOP.
I would like to know possible improvements (the method main loop is too rock and roll, if you have suggestion to reduce it and improve readability).
Code:...
1
vote
1answer
125 views
Automate the Boring Stuff with Python 2nd Edition - Sandwich Maker Practice Project
I am in learning process, even though its a very easy project, I still want experts to please review it and share the improvement that can be done, if anyone wants to use other modules to shorten the ...
4
votes
1answer
159 views
Finding Pattern Score in Python
I saw this problem in C++ on here and decided to try it in Python, which was much simpler. I've used the same problem blurb as in the link above, so they are consistent. I'm sure my code can be ...
3
votes
0answers
32 views
Assembly REPL in Python using ctypes
I created a assembly REPL using some ctypes hacks to run the assembly code. Any suggestions on how I could improve it? I am unconcerned about some of the "obvious" security issues such as ...
1
vote
1answer
101 views
How to find the next sequence of integers?
I was thinking of the following problem: List all sequences \$ a_1, a_2, a_3, a_4, a_5, a_6, a_7 \$ of positive integers where \$ 1 \le a_1 < a_2 < \ldots < a_7 \le 39 \$. For any sequence ...
10
votes
3answers
197 views
“superior” input function
Have you ever written a python script, then got to a part where you have to get input from the user?
I would assume your code went something like this:
...
2
votes
1answer
54 views
Manage list of subjects (show, delete, add) in Python
This is my code. It loops a menu, from which you can select whether you want to add a subject, see all subjects or delete a subject. Is there anything style- or functionality-wise to add or correct?
<...
3
votes
1answer
56 views
Program to move in a 2d array given instructions, array and starting position
Original problem (not in English): https://pokval21.kattis.com/problems/pokval21.robotdammsugaren
How can my code be optimized?
...
5
votes
2answers
227 views
Program Arcade Games: Ch 16 Worksheet 2D-Array Algorithm
The check_celebrity() function below takes an n*n grid as its parameter and prints the celebrity if there is one.
A celebrity is ...
1
vote
1answer
49 views
Check Windows computer's usage of CPU and other resources
I am new to Python and tkinter and I made software which checks Windows computer's usage of: CPU, RAM, Storage, Upload Speed, Download Speed, Latency and Ping. If the output exceeds the input, an ...
3
votes
1answer
58 views
Multiple if-statements with overwriting lists
I currently have the following piece of code in place that attempts to find matches within a list, based on a priority system:
...
5
votes
1answer
58 views
Web Crawler for notice of assessment retrieval
Context: I want to check if notice of assessment are valid.
What I did: I wrote some code to extract textual information from PDF (with OCR on image contained in the PDF): ...