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

learn more… | top users | synonyms

0
votes
0answers
11 views

Simple name-drawer using Python and Tkinter

I am a beginner playing around with Python and Tkinter. I wrote this program to draw random names given the students in my classes. I tried to follow PEP 8, but I was wondering if there are any ...
0
votes
0answers
5 views

Script that processes filenames and grabs data/PDFs from the web [on hold]

I want to implement this using requests or just urllib[2] instead of selenium. I spent many, many hours googling to figure out how to, with lots of testing, but I was simply never able to. I'm a ...
2
votes
0answers
14 views

Probabilistically pick a candidate

I have a list of candidates which looks like this: ...
-1
votes
1answer
15 views

SPOJ prime generator problem in Python 3

I am trying to solve an SPOJ problem using Python 3: print all prime numbers in a given range (as large as 109). ...
-3
votes
0answers
23 views

Unsure about where to start python probability [on hold]

I am trying to code a script for the site CSGODOUBLE.com. It is basically a roulette site for csgo skins. I have a basic vision of what I want and have made a start but am a bit unsure on some of the ...
0
votes
0answers
20 views

Theano code for 2-layer neural net for mnist

I did not attach the data, but it is the standard mnist in CSV format. I am getting around 92% accuracy. I know there is no momentum that may be improving accuracy, but still, it seem way too low, I ...
0
votes
0answers
11 views

Python Tk Textpad Finding and Highliting Words [on hold]

I have written a PyDBG powered Tk debugging tool. I finished all the debugging aspects and thought it looked a little dull. I pipe all of my output to a text pad as the main source of information and ...
0
votes
1answer
23 views

Counting distinct lists in a list

I'm trying to remove the duplicate from the list and count the list after removing the duplicates ...
5
votes
2answers
533 views

Hangman from a beginner

I'm trying to learn programming with python by myself and I've made a hangman game for exercise purposes. ...
1
vote
1answer
80 views

AI Tetris-like game

I was thinking to rewrite my Python code to C++ since it contains quite a lot of simple loops. I was stunned to find out that this critical part of code (the code below) is about 5 times slower than ...
0
votes
1answer
11 views

Django query filter on count in one to many relation

I have the following models: Donation Charge - donation = models.ForeignKey(Donation) - error = models.CharField() # contains the error, can be null/blank And I ...
-1
votes
0answers
11 views

Trouble understanding Tower of Hanoi code in Python 2-7 [on hold]

As I mentioned in other posts, I am learning programming mainly for my hobbies. A month or so ago, I decided to stop where I was at learning C and Java and to start learning from the ground up so to ...
1
vote
3answers
51 views

3n+1 problem rejected by uva judge: time limit exceeded

I am trying to get into the habit of solving programming puzzles in my spare time but am stuck on the first one(which I know can be for a large number of reasons hence my posting for help). Shown ...
4
votes
1answer
41 views

Transparent wrapper class for data structure in Python

I needed a deque who's maxlen can be set again after it has been initialized. So, since new-style classes in Python are treated ...
8
votes
1answer
44 views

ChickenDodger game written using Pygame

I just made my first pygame program, ChickenDodger, and I would like to know how I could make my code better. I think I did pretty good for my first time, except the way I added the 2nd egg. I do not ...
5
votes
2answers
70 views

Monte Carlo simulation of amoeba population

I wrote a simple Python simulation to answer the "Amoeba" population question posed here: A population of amoebas starts with 1. After 1 period that amoeba can divide into 1, 2, 3, or 0 (it can ...
1
vote
2answers
49 views

Calculate difference between two times

I just wrote this script that calculates the time difference between two times. It's going to be used in a larger program that will store the returned value in a database. I'm mainly wondering if ...
1
vote
0answers
21 views

Finding cointegrated pair with minimal t-score

The function findMinimal() receives a tuple from a list which contains 171 tuples, each of them go into the function one by one and, for each tuple, it searches the ...
-1
votes
0answers
31 views

2D Grid search in larger 2D Grid [on hold]

The goal is to return a boolean as to whether the 2D search area exists in the larget 2D grid. My logic is as follows: Find the first occurance in the grid that equals the target grid Find all ...
8
votes
2answers
91 views

Finding a string whose MD5 starts like the digits of π

I tried to make a program to find a string whose MD5-hash starts like the digits of pi, where dot is omitted. Is there a faster way to do it than this: ...
-3
votes
0answers
23 views

why isn't a dictionary being populated? automate the boring stuff excel census chapter [on hold]

New to all of this. Using linux, python 3.4 and openpyxl and doing the exercises from ATBS. Why am I not getting a fully populated dictionary? I am only getting the results from one row. The excel ...
3
votes
1answer
29 views

Slicing a big NumPy array

I have a function that takes a four-dimensional NumPy array M and, for each value i of its second index, takes all of M without the i-th "column", evaluates the product over all other columns, and ...
0
votes
2answers
48 views

Effective Python 2/3 two-dimensional array initialisation

Recently I noticed that the idiomatic python two-dimensional array initialisation is extremely slow. I am wondering, is there a good, proper way of doing this simple task fast? Also, are those two ...
1
vote
0answers
37 views

Checking convergence of 2-layer neural network in python

I am working with the following code: ...
3
votes
2answers
118 views

High execution time of LCS length program in Python2

I was trying to solve the Longest Common Subsequence problem on a HackerRank exercise. It's quite simple and straightforward, just print out the length of the LCS. I submitted this code: ...
0
votes
0answers
20 views

settings.py for Google App Engine webapp

I have a Google App Engine webapp and would like you to review my settings file. Isn't it better to keep secret keys and provider data in the datastore or in a properties file rather than the code? ...
-1
votes
0answers
42 views
6
votes
3answers
370 views

Storing hashed passwords

I'm a beginner and am self taught and was hoping I could get help from others more educated than me to show me what bad practices I might be forming before I go on further. P.S. This program is just ...
-2
votes
0answers
12 views

Python Generate and Execute Statements [on hold]

I have a series of statements that needs to evaluated with every iteration Currently I'm able to print the statements but I'm unable to execute them ...
4
votes
1answer
71 views

Intersections of two lists

Given two python lists a and b. These lists may intersect (It is possible that lists intersect more than once). An example: ...
1
vote
1answer
40 views

What is the best way to extract method?

The code snippet is what I want to do. Previously I use a different version of my code. But it is out of joint according to Python coding guidelines because I was assigned my lambda function to a ...
3
votes
1answer
35 views

Maximize points won by flipping coins

So, there is this king-of-the-hill challenge going on at PPCG SE to which I submitted my participation. I won't change it further in terms of behaviour, so I wanted to know what you think of the code. ...
-4
votes
0answers
17 views

Read a specific row in csv on python [on hold]

I have a csv file on exel: ["11811818","apple" ,"0.75"] ["11811817","bannana","0.60"] In my python program I need the user to input a barcode [column 1] and the ...
1
vote
1answer
34 views

Longest Palindromic Substring

I wrote the following code for this problem. The problem is to find the longest palindromic substring. I think it is correct and is working correctly for all the test cases I entered myself. Now, the ...
1
vote
2answers
43 views

Compare function for lists

I need to sort a list of lists. The following is a compare function: ...
8
votes
3answers
301 views

Removing all duplicated pairs in a Python list

I need a function to remove duplicated pairs from a list. The following is example list: a = [1, 1, 1, 2, 3, 5, 4, 4, 5, 2, 3, 3, 2, 3, 1, 6, 6, 6, 6] I need ...
-1
votes
0answers
11 views

How do i make this script work for any input file [closed]

i have this little script, it works my only problem is making it work for any input .csv file i throw at it. So far it only works if i specify exacly the file inside the function. ...
2
votes
2answers
40 views

Program to edit an address book stored as a JSON file

I was told to come here from Stack Overflow. I'm trying my hand at an address book and the goal is for it to have a bit more of error prevention, for instance for the key "phone" to have 10 digits, ...
1
vote
1answer
23 views

Python list “commander” (modify a list with user commands)

I made a program that can modify a list using commands that the user enters. The commands that are supported are (used from actual program): ...
7
votes
4answers
1k views

Simple python calculator

I'm very new to Python, and so I'm trying to learn it by doing simple programs, like a calculator. But I don't know if this is the "Pythonic" way to do it, or if I am making beginner errors. So ...
1
vote
2answers
19 views

Finding all non-empty directories and their files on an SFTP server with Paramiko

The purpose of the following function is to find all non-empty directories, and the files in those non-empty directories. It recursively checks each directory on an SFTP server to see if it has any ...
-2
votes
0answers
12 views

Combat game that keeps track of in-game stats and increased difficulty levels [closed]

Was curious of a more efficient way to accomplish the same tasks. ...
3
votes
1answer
26 views
3
votes
1answer
56 views

Chopsticks Game in Python (Version 2)

This is another iteration of my previous question. This program plays the game Chopsticks using the Minimax algorithm. I search the tree using recursion. The problem, however, is that it is just ...
2
votes
2answers
33 views

Find the best path amongst N random points

For an application with a graphical canvas, I want to generate N points. But then I want to link those points, and I want to find the best path through those points. I wanted to use a dynamic ...
-2
votes
0answers
20 views

How do I complete this Python Tennis Kata? [closed]

I'm trying to write the Tennis kata in python. I've written the code for a standard game, but somehow cannot figure out how to write the Deuce part. Could someone give me an algorithm or help me ...
3
votes
1answer
41 views

Decorator that supplies arguments to functions

I have assignment to generate argument based decorator I wrote like this. ...
0
votes
1answer
50 views

Exponentiation using while loop in Python

I could not think of any better way to raise to power, except this, but how do I refactor it? I should only use while loop, not for loop, not x**y. I shall not use pow(x,y) ...
1
vote
0answers
22 views

PEG parser generator

I wrote a Python PEG parser generator that takes a grammar as a string, and returns a parser. The parser can parse its own syntax, and is feature complete with the original PEG paper, with some ...