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

learn more… | top users | synonyms

2
votes
0answers
9 views

Renaming PDF files based on given rules in a text file

I'm learing Python by writing a program to solve some housekeeping I do weekly, namely renaming PDF files according to rules given in a text file. My end goal is to have idiomatic Python, with full ...
-1
votes
0answers
11 views

Is sometimes single precision computation is more precise [on hold]

I want to show that sometimes calculation with single precision(SP) is more precise. So I wrote this code to indicate that using double precision(DP) numbers make my computation erroneous. Is there ...
3
votes
1answer
13 views

Implementation of the change making algorithm

I wrote a set of python classes for solving the change making problem, in various forms. Given the coin denominations and values: Find all possible ways of making change. Find a best way ...
-5
votes
0answers
24 views

calculating epoch time from path name of (year/month/date/hour) [on hold]

I have millions of folders with the path 'year/month/date' containing files with the hour on them in the first 2 characters like '03....' would be for 3AM. However, my code looks kinda messy and I'm ...
0
votes
0answers
14 views

Make statistics according to multiple keys

OK, this time my code is so much, so I will explain what I am doing at first: In a word, I am doing a statistics according to (year, location ,bz, batch, wl, school), if I explain what these ...
6
votes
1answer
85 views

Thread-safe memoizer

I have searched around but I was not able to find a complete implementation of the memoize pattern in a multithreaded context. It's the first time playing with thread synchronization. The code seems ...
3
votes
3answers
92 views

Build a dictionary based on split string

I've written a simple script that takes a string filled with brackets and strings and builds them to a dictionary. Example Input: ...
-4
votes
0answers
17 views

Python code to play Alarm after reguler interval [on hold]

Following code is able to play music file and run Message box on the screen, Rather than performing task after "9 seconds" it takes around 25 seconds to play music. Please suggest optimisations. ...
-2
votes
1answer
27 views

Finding longest list in list of lists in Python

I have the following code to find the longest list in a list of lists: ...
7
votes
2answers
139 views

Script for a Civil War game

I'm new to Python, and pretty much programming/scripting. I'm just looking for someone to critique my methods and tell me if there are more efficient ways to do things. ...
3
votes
2answers
43 views

Lazily combine ranges dependent on modulo with one loop

I have a positive integer n. I want to lazily loop over a range of integers less than n consisting of a) integers divisible by 3 ...
0
votes
1answer
58 views

Project Euler Problem 11 (“Largest product in a grid”) in Python

Can this code in any way be improved or optimized? I'd appreciate any clever tricks or Pythonic expressions that may remove some more brute force elements from my solution. Also, is there possibly a ...
3
votes
2answers
35 views

Diceware Passphrase Generator

I've written a simple Diceware passphrase generator based on this Stack Overflow question and the top answer. Briefly, in the Diceware method, a die is rolled 5 times for each word in the passphrase ...
12
votes
1answer
82 views

Convert any number (up to 10^3000) to text

I kinda got the idea after playing Adventure Capitalist, since that goes up to 10300. I found a website that explained how to go up to 10^3000, so I mainly did this as a challenge to see if I could do ...
1
vote
1answer
30 views

Optimizing game camera

I'm moving some octagons around and I found a serious bottleneck: ...
1
vote
0answers
42 views

Iterated root-finding and optimization

I am quite new to Python and I have trouble finding the roots of a function. The ultimate goal is to find $$y=(a_1,p_0,\theta)$$ such that they minimize the function $$-\sum\limits_{j=1}^{n} ...
4
votes
2answers
46 views

Solver for Jumble puzzle

Here is my first attempt to solve Jumble puzzle: ...
5
votes
1answer
78 views

Functional programming in Python: 2048 merge functions

I've written the core functions for a basic 2048 game. I know Python isn't a functional programming language, but I like the "functional style" (easier to maintain, simple to understand, more ...
0
votes
1answer
57 views

The mood of the nation - Twitter trend

This assignment is taken from here. Introduction In this project, you will develop a geographic visualization of twitter data across the USA. You will need to use dictionaries, lists, and ...
2
votes
1answer
24 views

Denormalizing an OrderedDict to CSV

Cross post from stackoverflow, as suggested. I have an ordereddict, and I need to store it in CSV file. Input: ...
3
votes
1answer
45 views

OOP TictacToe with Tkinter

This is my implementation of a Tic Tac Toe game with Tkinter GUI. So far I've set up the game to play with another player. For an interview coming up, I am suppose to build additional feature such ...
5
votes
2answers
62 views

Sum of successive powers of digits

Some numbers have funny properties. For example: $$\eqalign{89 &→ 8^1 + 9^2 &= 89 &= 89 × 1 \\ 695 &→ 6^2 + 9^3 + 5^4 &= 1390 &= 695 × 2 \\ 46288 &→ 4^3 + 6^4 + 2^5 + 8^6 ...
2
votes
0answers
27 views

Factory for arbitrarily high-order operations

Grade 0: ++ This is so low that it is boring; the operation of grade 0 is incrementing or counting up, for example: ...
7
votes
3answers
217 views

Google Foobar Challenge: Save Beta Rabbit in Python

I'm going through the Google Foobar challenges and am currently on the first challenge of level three. I've come up with a working solution, however, it's not an acceptable solution because it runs ...
1
vote
3answers
57 views

Top-10 lists of occupations, ranked by various attributes

In the code below, all pairs of functions are very similar: set function rankListId is different rankListName is ...
4
votes
2answers
46 views

The Geometry of Maps - Twitter Trend

Below assignment is taken from here. Introduction In this project, you will develop a geographic visualization of twitter data across the USA. You will need to use dictionaries, lists, ...
2
votes
1answer
38 views

Parse a string as a list of words and parse characters

I'm trying to create a list from a string with items alternating between words and parse characters like ['Hello', ' ', 'World'] Is there a built in function, ...
5
votes
1answer
60 views

Python factory method with easy registry

My aim is to define a set of classes, each providing methods for comparing a particular type of file. My idea is to use some kind of factory method to instantiate the class based upon a string, which ...
3
votes
0answers
28 views

Running a version of Space Invaders

I made a program that runs my version of Space Invaders. I recently finished it. I just want to make it more pythonic, and streamline it so it uses less memory and performs faster. The basic outline ...
-1
votes
0answers
10 views

Using a dictionary to index words in a document per line [closed]

I'm trying to create a dictionary by indexing word occurrences. The index will be the word and the item will be a list of the line numbers that it is on. So far I have this and it works, kinda. It ...
2
votes
1answer
46 views

Move through a basic roguelike text map

I have a basic outline for the best way I can come up with to move a character through a basic text map. I want to implement this module in my simple text RPG. I know there has to be a better way to ...
0
votes
0answers
11 views

Python help lazy loading large data sets [closed]

I have a script which loads data into a database. I grab data from csv files and return a generator. The values yielded from the generator are used to build insert statements for bulk loading up to ...
3
votes
2answers
78 views

Assembler for Hack Assembly Language in Python

My Python implementation of for Hack Assembly Language. See this question for the Java implementation. Any comment about best practices and performance improvement? ...
2
votes
2answers
46 views

Python Command Line Rock Paper Scissors

I'm looking for tips on how to clean up this code and/or make it more efficient. Keep in mind I am a seriously new programmer and if it is too advanced it's likely to go over my head. ...
5
votes
1answer
54 views

Assigning sentiment to each tweet - Twitter trend

Below assignment is taken from here. Introduction In this project, you will develop a geographic visualization of twitter data across the USA. You will need to use dictionaries, lists, ...
3
votes
3answers
60 views

Minimum Value evenly divisible by all integers from 1 to n

I have just started learning python and I am solving Project Euler problems alongside for practice. This is my solution for problem 5. Project Euler asks for the minimum value divisible by all numbers ...
4
votes
0answers
40 views

Temporary file utility class in Python

I decided to write a tiny class to automatically write and delete a file given filename and content. It is intended to make testing IO less verbose. I include a small example usage. ...
3
votes
1answer
20 views

Fetching, processing, and storing Mixpanel analytics data to SQLite

I'm a self-taught Python programmer and I never really learned the fundamentals of programming, so I want to see how to improve upon this script and make it adhere to best practices. The script has ...
1
vote
0answers
29 views

Covering Array Sorter

A covering array is a N x k array in which each element is a from a set of v symbols, and ...
1
vote
1answer
45 views

Parsing video files from a given directory

I have written a little class that is basicly looking for video files in given directory and then parsing some info about those files. Finally it saves everything in a list. To properly run this you ...
10
votes
4answers
1k views

Simple text RPG in Python

I am trying to teach myself to code using Python. The following is the first real program I have written from scratch. I feel that it is messy and in need of improvement, but I am either unsure of ...
0
votes
0answers
19 views

BeautifulSoup web spider for driver links

The following spider will grab some driver links, OS version, and the name. All the info is in a table class, but some pages might be a little different in the location and Number of cells in each ...
-1
votes
1answer
38 views

Function for shuffling cards

Assignment from here Q6. Define a function shuffle that takes a list with an even number of elements (cards) and creates a new list that interleaves the elements of the first half with the ...
2
votes
1answer
52 views

Parsing oscilloscope data, follow up

Follow-up up on Parsing oscilloscope binary data. I wrote a simple parser for Tektronix's internal file format .isf. I revised my code to the following: ...
2
votes
1answer
28 views

SPOJ “SBANK - Sorting Bank Accounts” TLE

I am new tro programming and have chosen python 2.7 to begin with. But, I often have to deal with a TLE while competitive coding like in the problem below, where my code runs fine on all test cases ...
8
votes
1answer
73 views

Drawing circles with triangles

As pyglet has no in-built method to return a vertex list of circle, I had to build one myself. This is a critical piece of code that I will use very frequently. I need it to be of very fine ...
-1
votes
0answers
16 views

Login class for a Tkinter app [closed]

I have this code working for logging into my main root, but I would like to know if there is a better approach to it. class Login: ...
-1
votes
0answers
12 views

Gronsfeld Cipher code gone wrong [closed]

I wrote a code on CodeEval to decrypt text ciphered with Gronsfeld Cipher. In short, the instructions are: Vocabs: ...
2
votes
1answer
13 views

Simplified doctest

The doctest module seemed easy to implement so I decided to write a simpler version of it. my_doctest.py ...