Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

learn more… | top users | synonyms

-1
votes
0answers
9 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
114 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
19 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
40 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: ...
9
votes
0answers
41 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 ...
3
votes
1answer
91 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
137 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
10 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
33 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
41 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
56 views

Print grades in table form [on hold]

I want help. I wrote my program but it should return this: ...
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
38 views
-3
votes
1answer
61 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
55 views

How to repeat the while loop in my crazy numbers program [on hold]

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
111 views

Python palindrome checker

This is my palindrome-checker It is doing what it should do ...
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

MAX occurring char in a string [on hold]

Please let me know how to improve this code. ...
5
votes
2answers
33 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
37 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
92 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
27 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
59 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
142 views

Nondeduplicating mutual membership testing

Python sets are magical things. Mutable, deduplicating data stores with handy operator overloads for &, ...
-3
votes
0answers
31 views

Python: How to get rid of the memory error? [closed]

I have the following code: ...
3
votes
1answer
46 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
24 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

Preventing floods while saving logs

I had a logging function… ...
7
votes
0answers
83 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
18 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
47 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
29 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
57 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 [closed]

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
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
65 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
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 + ...
1
vote
1answer
32 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
65 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 ...
6
votes
4answers
821 views

Fast Number Factorization in Python

Here's my implementation to factorize a positive integer: ...
5
votes
3answers
168 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 ...