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

learn more… | top users | synonyms

0
votes
0answers
9 views

Python algorithm for identification of low-level jets 2 (meteorology)

I'm looking for suggestions to improve my algorithm for the identification of low-level jets in wind data. I have wind measurements at several heights, and I want to identify jets according to the ...
2
votes
1answer
11 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
0answers
11 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
13 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
20 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
9 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
40 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
22 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
18 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
58 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
103 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
27 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
59 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
23 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
39 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 [on hold]

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

Fast Number Factorization in Python

Here's my implementation to factorize a positive integer: ...
5
votes
2answers
127 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
41 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
29 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
1answer
30 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
40 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
18 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
30 views

Random Number Generator PYTHON [on hold]

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
353 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
71 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 ...
5
votes
2answers
67 views

Randomized Lighting with Python

I use this to automate the lights in my home while I am away at night (simulating presence). The scheduling of when this runs is handled by my home automation software (Indigo Domotics). I'm open to ...
6
votes
3answers
52 views

Korean word segmentation using frequency heuristic

This a continuation of a previous question. I want to thank Joe Wallis for his help with increasing the readability of my code. Although the changes made by Joe Wallis did increase the speed of the ...
2
votes
1answer
23 views

Measuring the distance between NumPy matrixes

This takes two sets of five random points stored as a NumPy matrix, and then calculates the NumPy matrix between a point of the first set and a point of the second set. While the code works, I feel ...
4
votes
2answers
98 views

Adventure Game Project [closed]

I made an adventure game, it is unfinished at the moment but not far off. Here is what I have so far: ...
3
votes
2answers
49 views

Python Caesar Cipher

I am a student doing their AS Computing course and I have created a piece of code in which a message can be typed and then scrambled by moving letters along the alphabet. I was wondering if anyone ...
1
vote
2answers
45 views

Bricky - A Breakout Clone in Pygame

I've been working on learning Pygame and I made a Breakout clone. I'm looking for stylistic advice and overall suggestions for improvement. Controls are simple: - ← and → to move. ...
3
votes
3answers
68 views

Application that processes XML based on configuration

I used CodeClimate to evaluate my code and marked that the following piece of code appeared twice in my source: ...
2
votes
2answers
103 views
+50

Parsing JSON in one go

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 ...
-1
votes
0answers
33 views

creating this string representation for this puzzle [closed]

i am trying to make this jigsaw puzzle. class is jigsaw and im trying to import this script called Piece. ...
-5
votes
0answers
22 views

How can I make a programme create an answer for an automated QW? [closed]

I'm having some trouble programming in Python in which I hope someone can help me. Basically, I'm creating a maths arithmetic quiz and want it to asks 10 automatic random questions by using the WHILE ...
-5
votes
0answers
24 views

Generate non registered vehicles number plates in Python [closed]

The code should identify any vehicle registrations that do not match the pattern of the U.K. Standard vehicle registrations (2 letters,2 numbers,3 letters e.g AZ01 XYZ) A list of non standard ...
4
votes
1answer
37 views

Project Euler - Largest Product In A Grid

My code solves Project Euler problem #011: What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid? I looked over one ...
0
votes
2answers
63 views

JSON string parsing

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 ...
4
votes
1answer
37 views

Find if items in a list of list matches to another list

We have two lists: ...
4
votes
2answers
50 views

Python command-line Tic Tac Toe for two humans

I’d love some feedback on this human v. human, tic tac toe game I wrote in Python 2.7.10. I’d love to hear your thoughts on optimization and making the code simpler and more “pythonic”. Also, I’m ...
26
votes
3answers
1k views

Bush Wanderer - code intended for teaching

I am teaching computing to an AS class and this was their assignment: Bush Wanderer Task 1 Create a 5x5 grid of hashes(#) where the player is an ...
1
vote
1answer
33 views

A piece of Python code to compute a frequency table of a list of values

I have written a Python 2.5.4 function which accepts as input a list of numbers alongwith the desired number of classes and yields a frequency distribution (i.e. a histogram) of the same data. While ...
2
votes
1answer
50 views

Program to email you exchange rates that you are tracking and stats on them

This is a program I made as I am currently living in Japan with a British bank account, so exchange rates matter to me. On the first time run, you run the script with two arguments (two currencies) ...
7
votes
2answers
80 views

Fast Python spring network solver

I wanted a very simple spring system written in Python. The system would be defined as a simple network of knots, linked by ...
2
votes
0answers
31 views

Execute commands over Telnet, logging to a file

I have made some code that will login to a device and send all your additional commands. It also logs the commands and the returned values to a file on the local system. Hope somebody can tell me if ...