Tagged Questions
Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
2
votes
2answers
41 views
Python simple battleship game
I'm relatively new to Python, I decided to make a simple battleship game. Is there anything I should do to make it shorter, or in practice, "better"?
...
3
votes
1answer
42 views
Arithmetic quiz with class database and score analysis
I have done this quiz project and I have tried as hard as I could when I was writing to make it user friendly to read. Could you help me on improving and making it more user friendly please.
...
-2
votes
0answers
10 views
My code returns a value for the last iteration date, and not for the entire iteration [on hold]
My function reads a CSV file consisting of dates with times and sentiments(positive, negative and neutral). It returns three dictionaries (positive_dict, ...
5
votes
2answers
56 views
Coloring a string in a terminal
I have this code which makes it easy to color a string in terminal but it is looking really repetitive. Is there a more idiomatic way of writing this? Also is there a functional way of doing this more ...
1
vote
0answers
9 views
Kivy language code of my Vehicle Details app
So I've written my first android app in kivy.
This app takes a Vehicle License Number as input from the user and submits it to a sites and shows the results from the site.
The complete Source Code ...
6
votes
1answer
32 views
Aligning out-of-sync subtitles
This is my 2nd program I wrote on my own, a pretty simple program consisting of two functions (those functions are not combined in any way yet though). The first function moves the display times of ...
12
votes
2answers
1k views
Python backend interview: task management system for workers
I've recently applied to a backend position and I was asked to complete a take-home interview question. I thought the question was rather simple and I completed in about an hour although I was told it ...
-2
votes
0answers
17 views
Stacked bar charts using python matplotlib for positive and negative values [on hold]
I am trying to plot a stacked bar chart with python Matplotlib and I have positive and negative values that I want to draw. I have had a look at other posts talking about how to plot stacked bar ...
3
votes
1answer
132 views
Simple Hangman game in Python
I recently started learning Python, and made a simple text based Hangman game. I wanted to know if there could be anything done to make the code cleaner or more efficient.
...
3
votes
1answer
28 views
Putting a matrix from a text file into a list
I'm trying to read a text file with matrix and put it in a list, but I am using two loops here and I want my function to be faster.
...
1
vote
1answer
44 views
Charging battery animation over time
I have the following method that is working perfectly. Main problem I see is that I think it can be done just in one line, but I don't know how:
...
10
votes
3answers
69 views
n-queens puzzle in Python
I want to increase the efficiency and reduce the time complexity for the n-queen problem in n*n matrix chess. I am able to run only still (11*11) in normal time otherwise for the big number it is ...
4
votes
1answer
114 views
Finding the longest path, avoiding obstacles in a 2D plane
The Scenario
You are given a matrix of size m x n (width x height) with m*n spots where there are a few obstacles. Spots with obstacles are marked as 1, and those without are marked as 0. You can ...
3
votes
2answers
145 views
“Guess my Number” game in Python (2.7.9)
First time posting to Code Review. Just looking to get some advice on how I can write better code.
I found the following exercise for a "Guess my Number" game on DaniWeb, but the linked source code ...
2
votes
1answer
17 views
Redshift Load and Unload Wrapper class
We do constant traffic with our Redshift tables, and so I created a wrapper class that will allow for custom sql to be ran (or a default generic stmt), and can run a ...
-4
votes
1answer
36 views
How to make a general coding from my code? [on hold]
example a=[8,-1,6]
I'm trying to name the first number as x1 and the rest add them together as ...
-1
votes
0answers
43 views
Memory efficient alternative passing mostly static variables w/ 1 dynamic variable to an external function (COM) instead of a for loop in Python
Massive data problem, 7/8 variables are repeated 1000 times in a for loop, sending 8 input vectors * 50,000 values per loop for each function call. Only 1 input ...
-2
votes
0answers
58 views
2
votes
0answers
17 views
Adaptive scan of function concurrently
This function try to scan the given function in n dimensions in the given range by adaptively divide the area into n+1 points polygon (e.g. triangle in 2D; tetrahedron in 3D)
I tried to seperate the ...
2
votes
2answers
39 views
-2
votes
1answer
75 views
Parsing JSON in one go using state machine solution
I need to parse a simple JSON string (flat JSON, no hierarchy)
for keys and values, and there is a system constraint
that I cannot use any built-in JSON library and can only
read a string once due to ...
-6
votes
1answer
58 views
How to repeat the while loop in my crazy numbers program [closed]
So my code is too complicated and there are way too many errors. It works just fine with the long steps, but I need to make it simpler, and I can't figure out how to do a while loop. Help ? (This is ...
3
votes
5answers
118 views
3
votes
1answer
34 views
Something to store any (standard) data in python
I decided to try make my own way to save normal python data yesterday after coming across the minecraft NBT format, it's more limited than cPickle but appears to produce shorter results and so far ...
-1
votes
0answers
12 views
7
votes
2answers
39 views
CLI Twitter client in Python
Here is a simple client for Wwitter that I wrote based on the twitter library in Python. The aim is to be able to read the feeds from different twitter accounts ...
5
votes
0answers
39 views
Copy files mentioned in an Excel sheet
Please help me in reducing the time complexity of this code as it is taking a long time to read its Excel input.
...
2
votes
2answers
95 views
Functions to merge dictionaries with a comparison
I have several functions for merging some dictionaries but over time I created a more general function that would make all these others obsolete if it weren't slower.
I have the specialized (and ...
1
vote
2answers
29 views
XML Python can this be improved
ok spent ages on this simple problem (I'm not good at XML) below code is probably self explanatory and it works, but i think this could be done a lot easier
Sample XML
...
5
votes
1answer
62 views
Text Based: Player vs Player Tic-Tac-Toe
Just looking for a review on my code, its currently only player vs player, but I'll be working on the AI soon enough. Functions edit_name, tutorial, and AI have been left out as I haven't started work ...
2
votes
2answers
56 views
Counting significant figures in a number
I decided to make something to count the significant figures in a number to see how easily it could be done, but I think there may have been a better or simpler way. Any advice even just for ...
5
votes
3answers
149 views
Duplicate-preserving collection intersection
Python sets are magical things. Mutable, deduplicating data stores with handy operator overloads for &, ...
-3
votes
0answers
32 views
3
votes
1answer
47 views
Workaround for the precision limitation for Python's round() function
I'm trying to come up with a general way to correctly round floats with Python, given the known limitation of round():
Note: The behavior of ...
3
votes
2answers
25 views
Modify and import as numpy.ndarray a txt file in python
To import the data contained into the file my_file.txt that have the form:
...
3
votes
3answers
68 views
10
votes
1answer
121 views
+50
Fuzzy grep for fuzzy bears in pure Python
I am aware of the Python modules galore to do this, but this was partially a learning experience and partially all the functionality I need and no more.
I'm writing a simple interpreter for a ...
-3
votes
0answers
20 views
Python audio import sounddevice as sd (ImportError: No module name sounddevice) [closed]
I am trying to use a raspberry pi to receive microphone input and add an effect outputting a low pass audio filter effect on the microphone input in real time.
I have python code that is running on ...
2
votes
1answer
54 views
196-Algorithm Program
Attempting to see whether using 196 as a respectively in my program will have a result or not, I made a simple function to test it. Now the 196-Algorithm requires ...
2
votes
1answer
48 views
Convert custom format to XML Template
I have just finished writing a simple Python3 program which converts a custom input file (or multiple files within the same folder) to an XML template.
It works as it is, but I think that I somehow ...
0
votes
1answer
30 views
Find csv item index
I'm quite new to Python and I have been trying to find a way to search a csv for a test string and return the index of that item in the csv.
I am using the code below but find it hard to believe that ...
2
votes
1answer
26 views
Optimize performance of flatten function in python
I have to flatten a large number (>300k) dicts to write them to a csv file.
Example:
...
1
vote
1answer
30 views
A simple log that tracks hours worked and and a python script that calculates wages
I wrote a simple Python script that will calculate income for a given month and hourly wage by parsing the contents of a log file. The instructions for how to use it is in my GitHub account here. The ...
1
vote
0answers
60 views
Interactive command line YouTube downloader with option to burn subtitles into video
This is only used on Mac machines. I know that there is a Python implementation of youtube-dl and several for ffmpeg, however I chose to use subprocess so that I can see the real-time stdout/stderr ...
2
votes
1answer
28 views
Distributed (asynchronous) averaging
This code simulates a distributed averaging protocol. There is a network of nodes, and at the clicks of a Poisson process:
A random node wakes up
Transmits it's current average to all the nodes it ...
3
votes
3answers
55 views
Tic-Tac-Toe project in Python
Here's a Tic-Tac-Toe program I wrote in Python. How can I improve it (.eg. make it more readable)?
...
3
votes
1answer
86 views
A phone troubleshooting program
The code should ask the user multiple solutions and find the problem with the users phone. The program should be efficient as possible and have a possible of 10 outcomes. I would like some tips on how ...
2
votes
0answers
25 views
Execute coroutines in pool
I want to run all the coroutines from the list in a pool of constant size and would like to ask if this is the right way how to achieve it. Is there any built in solution for this problem? I have not ...
4
votes
3answers
69 views
Extracting sleep quality scores from periodic readings
How can I optimize the next function to work faster? The function must prepare a list to put in a CSV file. The list must contain values of average percentage of sleep per minute counted from ...
4
votes
2answers
105 views
Regex for matching expression that consists of single digit numbers and operators
I would like to create a regex that will validate that a string is an equation made up of a single digits and either the * or + ...