Tagged Questions
Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
0
votes
0answers
3 views
python palindrome checker : how to not use the break part
This is my palindrome-checker
It is doing what it should do
...
0
votes
0answers
8 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
9 views
4
votes
1answer
13 views
CLI Twitter Client in Python
Here is a simple client for twitter that I wrote based on the twitter library in python. The aim is to be able to read the feeds from different twitter accounts ...
4
votes
0answers
25 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
72 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 ...
2
votes
2answers
21 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
46 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
50 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
135 views
Nondeduplicating mutual membership testing
Python sets are magical things. Mutable, deduplicating data stores with handy operator overloads for &, ...
-3
votes
0answers
29 views
3
votes
1answer
44 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 ...
2
votes
2answers
20 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
63 views
5
votes
0answers
48 views
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
17 views
Python audio import sounddevice as sd (ImportError: No module name sounddevice) [on hold]
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 ...
-4
votes
0answers
13 views
Python import sounddevice as sd (ImportError: No module name sounddevice) [on hold]
1
down vote
favorite
I have python code that is running on raspberry pi B++ that uses the sounddevice library that lets you play and record sounds with python. I have successfully installed the ...
2
votes
1answer
50 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
44 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
28 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
28 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
35 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
26 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 ...
-4
votes
0answers
10 views
How can I scan a string of very large length [on hold]
I am using s = raw_input() to read the string but not getting right answer for very large len(s) ?
Please help me with that.
...
3
votes
3answers
54 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)?
...
2
votes
1answer
48 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
24 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
67 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 + ...
1
vote
1answer
30 views
Finding the percentile corresponding to a threshold
I need to find which percentile of a group of numbers is over a threshold value. Is there a way that this can be speed up? My implementation is much too slow for the intended application. In case this ...
3
votes
1answer
61 views
Python 4 Players Snake Game
I would really like to hear out some suggestions as well as general response to the code I've written for 4 players snake game. It's my first time using pygame module, as well as trying to design a ...
3
votes
1answer
26 views
Python Weighted Object Picker
I've designed a class ObjectPicker that can be given objects and weights. Objects can be picked randomly out of the ...
3
votes
2answers
53 views
Python algorithm for identification of low-level jets (meteorology)
A low-level jet is a local wind speed maximum near the surface. Baas (2009) defined a low-level jet as follows:
the lowest maximum of the wind speed profile in the lowest 500 m of the atmosphere ...
-2
votes
0answers
18 views
Where to incorrporate IF and Else if so if the file exist, it runs a process, if not it moves on to the next thing [closed]
Ignore the arcpy. I know some of this deals with python for ArcGIS, but my question and problem is python related. How would you skip the arcpy.Merge and arcpy.Clip if 'AAA010.shp' does not exist in ...
6
votes
4answers
815 views
5
votes
3answers
160 views
My first finished Python program: a deck of cards
I've recently started learning how to code in Python, and have even more recently learned the basics of object-oriented programming. Feeling inspired, I started on a program that would generate random ...
7
votes
1answer
42 views
Simple top down shooter game
This one of my first Python games in PyGame I decided to make for fun. Basically, you control a from top down perspective and shoot people in a maze.
This is the rewrite of the original code, and I'm ...
0
votes
0answers
33 views
SKlearn automate data pre treatment
I want to make a simple wrapper for sklearn models. The idea is that the wrapper automatically takes care of factors (columns of type "object") replacing them with ...
2
votes
3answers
16 views
Longest Collatz sequence in Python
I came across this problem:
The following iterative sequence is defined for the set of positive
integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
...
2
votes
1answer
36 views
Comparing course groupings to completed courses
I'm trying to do some basic math comparing some course groupings to completed courses. The original code shown below seems huge and maybe not pythonic?
I'm trying to write better view code then what ...
4
votes
2answers
41 views
Storing disassembled data in a structured way
I want to store the information returned by the dis function of the dis module in a structured way, using a dict, associating the mnemonics of each code of a line to the correspondent line number.
...
2
votes
1answer
19 views
In matrix of sub-matrices, select diagonal indices of off-diagonal submatrices
Let's say I have a square matrix of size (n*m) x (n*m) that is composed of n x n sub-matrices, with each submatrix being a square of size m x m.
I want to select the diagonal indices of the ...
1
vote
1answer
22 views
improvement of a database register function
Here is a function in a django rest api, that takes data in json and registers a category for a given website. I'd like to merge two try...except parts that check ...
-5
votes
0answers
31 views
Random Number Generator PYTHON [closed]
I've written a code, but I can't figure out where I've gone wrong. Can someone help? Thanks a million.
CODE -
...
3
votes
2answers
82 views
Simple function to generate a list of letters
I would like get some suggestions for improvement of this function, and alert me about any dodgy practices that you find.
I have been trying to learn python for a short time now and I would like to ...
2
votes
1answer
27 views
Wikipedia indexer and shortest link finder
I have the following code, how can I make it more efficient? Also, it doesn't always find the shortest route. (See Cat -> Tree)
...
5
votes
2answers
360 views
Beginner word-guessing game
I have the following code.
Aim is to guess a four letter string. Each letter can be tried four times. If the letter cannot be guessed, we go to the next letter until the fourth letter is reached.
I ...
-1
votes
0answers
46 views
hackerrank test not pass Project Euler #14: Longest Collatz sequence [closed]
i was just trying this problem in hackerrank but its not pass and i a little confused why, someone can give me a tip, code is:
...
3
votes
1answer
76 views
Simple Rock Paper Scissors Game
Note: This code was first posted on another forum by me under the name Candy. Read this note before you declare this code copied.
Since I was bored, I decided to code a Rock Paper Scissors game in ...