Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
10
votes
3answers
93 views
Reporting on Commissions
I want to condense down some of this, is there anything I can change to make it better or shorter?
It works now but I don't know what else I can change, are any of my if statements changeable to be ...
2
votes
1answer
38 views
Finding all divisors of an integer
The problem is to find all divisors of a given integer n.
(It may be better to implement a true prime generator, rather than a fixed set, as discussed with ...
-4
votes
0answers
17 views
very complicated Python puzzle [on hold]
I do not have a lot of knowledge in python coding its still fresh for me. However i have been given a scenario which i want to share with you and maybe someone can HELP me getting start it.. much ...
-1
votes
0answers
8 views
python create a subprocess to dispatch work? [on hold]
I am doing something like this:
main process just need to check is this task is ok, if ok just dispatch this job to other process.
and the process is something complicated, it has two parts,
this ...
-3
votes
0answers
12 views
**kwargs wont accept event parameter in pygame [on hold]
Like the title says down here you can see that i have an event handler that accepts two parameters the event and the object but for some reason i get an error every time i run the application. I am ...
5
votes
4answers
129 views
Checking for a win in Connect Four
I'm making a simple connect four game that I will eventually extend by creating an AI that the player can play against. Given that AI algorithms are reasonably complex, I find myself wanting to reduce ...
6
votes
2answers
34 views
Categorizing gene sequences read from a CSV file
I am relatively new to programming and would love to get some feedback on the following section of my code.
...
0
votes
3answers
76 views
Retrying a web request in Python
Is it fine to retry a web service call like this in Python? Would there be any scenarios the exception might not work the way we expect it? I expect it to continue only if it's fine, otherwise just ...
-1
votes
0answers
49 views
Text based adventure game [on hold]
I'm a (struggling) beginner trying to get to grips with creating a classes/functions based text adventure game.
The code below is the early stage of my game so far. I wondered if anyone could suggest ...
4
votes
1answer
26 views
MongoDB - Find records in one collection that match string in 2nd collection
I have a MongoDB collection of product IDs/unique products attributes and a second collection of codes that relate to attributes common for products whose IDs are prefixed with those codes.
For ...
5
votes
1answer
76 views
Transform Python math game to OOP
Background: I'm trying to learn basic OOP with Python. I have this program I wrote to help my son practice math problems. It does addition, subtraction, multiplication, and division. He can choose ...
3
votes
1answer
21 views
Searching the number with the biggest amount of odd divisors in an interval
I wrote this program for school (first year in college) and it works, but it's too slow. I wondered if anyone could help me optimize this a bit, because I've been trying and trying, but it just won't ...
-2
votes
0answers
18 views
Extracting array elements between two values in Python [on hold]
I am very new to python and I want to extract some elements from a 1911 x 2 matrix such that when elements in column 1 are between two values they will be extracted along with their corresponding ...
4
votes
1answer
30 views
Listening from Mongodb always and triggering
I am using classes for the first time. In this program I want the object to run infinitely so that any change in the MongoDB will trigger the function and do the necessary processing.
I am little ...
4
votes
2answers
51 views
Messaging API client function with many possible parameters
I'm working an open source project written in Python that is a wrapper to the Pushover API called py_pushover.
The main function of this wrapper is the ...
2
votes
3answers
61 views
Search engine scraper-aggregator
For some reason, I completely lost my reasoning with this code. I can't hold this simple logic for too long in my head. Actually, I want to improve this code, making it a little concise. The ...
2
votes
1answer
90 views
Triangle-numbers with lots of divisors (Project-Euler Problem 12)
The following is my python solution of project euler 12.
The sequence of triangle numbers is generated by adding the natural
numbers. So the 7th triangle number would be ...
3
votes
1answer
40 views
Mapping different classes to the same database table
I have several very similar subclasses that I (think I) want to be stored in the same database table. Most of the fields are identical, with each subclass adding 1 or 2 custom fields. My code is using ...
7
votes
4answers
116 views
Goldbach’s Conjecture in Python
Input Format
Input starts with an integer n (1 ≤ n ≤ 100) indicating the number of cases. The following n lines each contain a test case of a single even number x (4 ≤ x ≤ 32000).
Output Format
For ...
2
votes
2answers
51 views
Project Euler 22: Names scores alternative
Can someone tell me how to improve my following python code.
Code:
...
11
votes
2answers
89 views
Re-arranging an obfuscated address
I'm getting address (physical address, not digital) input that's obfuscated, and looks like the following:
The plaintext version:
...
5
votes
2answers
43 views
HackerRank: Encryption
Given a two-dimensional list, say some_list = ["ABCD", "EFGH", "IJ"], I am supposed to encrypt it by reading each column top to bottom, thus:
...
5
votes
2answers
68 views
Account registration system for a quiz game
As part of a school project for ICT lessons, our class has been required to write a quiz program following certain criteria that has been set. The first part of this is a program that handles the ...
2
votes
2answers
53 views
Find max difference for a given array
You are given an array of N integers, find the Max Difference where
the index of largest number is greater than the index of the smallest
number. If not find the next smallest number, so on and ...
5
votes
2answers
48 views
Sorting networks
Yesterday I read a fascinating article on Wikipedia about sorting networks.
Comparator networks are abstract devices built up of a fixed number of "wires" carrying values, and comparator modules ...
3
votes
3answers
50 views
Logic Gate Simulator - Proper Encapsulation
So I was checking out the courses on InteractivePython, and I came across this example to demonstrate inheritance.
My focus is on the Connector class and how it ...
3
votes
0answers
47 views
Locate missing or extra elements between two data sets with limited access to unique identifiers
I've written a python program that is responsible for making sure that all elements in one data set (let's call it the source) exists in another (let's call it the target).
Constraints beyond my ...
6
votes
2answers
553 views
HackerRank: ACM ICPC Team
I made a solution to this problem from HackerRank :
You are given a list of N people who are attending ACM-ICPC World
Finals. Each of them are either well versed in a topic or they are
not. ...
6
votes
5answers
107 views
Regex password strength test
I've been following a Python programming book and reached the Regex chapter where I encountered this challenge:
Write a password strength checker that checks if a password is:
At least 8 ...
1
vote
3answers
77 views
Longest common subsequence (LCS) for multiple strings
How would you improve this code? Particularly the check and check_all functions?
The time complexity of the algorithm of mlcs is \$O(|\Sigma|MN)\$, where \$\Sigma\$ is the alphabet, M is the number ...
2
votes
1answer
29 views
A way of keeping a constant game speed at any fps with Pygame
Normally the game speed with pygame is locked with the fps, so I attempted making a simple two classes that'd be super easy to use, to allow for the same game speed no matter what the fps is.
For ...
1
vote
2answers
28 views
Reimplementing enumerate() to produce a sequence or iterator
Apparently it is possible to implement enumerate so it produces a sequence when given a sequence, and produces an iterable otherwise. Sequence can be safely ...
3
votes
2answers
54 views
Tracking hours worked for the days of the week
I am working through a udemy course on Python, this is the first real program I've written. I am new to Python and to programming.
I'd like to replace the main ...
13
votes
3answers
240 views
Orbital Trajectory simulator
I have written a simple program to do trajectory simulation in the earth moon system, it still has a long way to go I am working on making it more class oriented and am looking into implementing A ...
5
votes
3answers
134 views
Web server to switch GPIO pin
I am running a simple Python webserver to toggle a GPIO pin
on a Raspberry Pi. All seems to work well, but I have a few
questions about my code (see below).
I am using the ...
6
votes
3answers
311 views
Project Euler 18/67: Maximum Path Sum
The complete problem definition can be summarized as "find the largest sum of for paths from the top to the bottom of a triangle of integers". I decided to read the triangle in from a file which can ...
9
votes
2answers
161 views
Search for a Pythonic Caesar
I implemented a second encryption algorithm: the well known caesar-cipher. This turned out to be longer than I expected. The "main" code is very concise, but the interface that followed seems a bit ...
5
votes
2answers
50 views
Searching Combobox drop-down list
I've created a Combobox GUI that allows the user to search through the Combobox by entering a letter on the keyboard. If user ...
3
votes
1answer
32 views
Check that input is list of lists of coordinates
I have a factory method that should accept a list of coordinate lists, which are pairs of numbers, for example ...
2
votes
3answers
103 views
English to Entean (V2) with maketrans
I wrote a python script that converts English to Entean language from an anime called "The Devil is a part timer".
This is the second version of the script which was first posted here Translating ...
4
votes
1answer
40 views
A matplotlib scatter function inside a for loop
This function is working exactly as I want, only, it's taking too long.
For speed ups, I've tried to do as much as I can before the main for loop by declaring ...
6
votes
2answers
75 views
Web Scraper in Python
So, this is my first web scraper (or part of it at least) and looking for things that I may have done wrong, or things that could be improved so I can learn from my mistakes.
I made a few short ...
3
votes
3answers
66 views
5
votes
3answers
166 views
Energy curve plotter
I am not much experienced in Python, just write some small script. All my codes are procedural. They work fine, and I always check them with pep8.
One of them is:
...
7
votes
4answers
623 views
RPG User File (Stats Holder)
This is my Player file. It is mainly for saving purposes. Is it easy to understand and read? Anything I should add or change for improvements?
...
18
votes
4answers
1k views
Translating from English to Entean
I wrote a python script that converts English to Entean language from an anime called "The Devil is a part timer". I am sloppy at coding and know that the script can be made better.
In the anime, the ...
7
votes
2answers
456 views
Text message “reverser”
I decided to step out of my comfort zone (Java) and try out Python. I wrote a very simple reverser.py and want it to be reviewed.
...
6
votes
4answers
182 views
Blocking production lines in Python
I have the following code that works great, but takes 40 mins to 1 hours to finish the task. It has at least 30 rules for blocking lines, and 30k+ orders to check. I'm new to Python (3 months working ...
4
votes
3answers
58 views
Finding a loop in a directed graph in Python
I wrote this code to find if a directed graph contains a loop or not. I am pretty new to graphs and I saw some examples on the internet but couldn't actually understand their implementations. So I ...
5
votes
2answers
115 views
Python rock paper scissors
My code implementing rock, paper and scissors in Python, using dicts to hold choices.
...