Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008.

learn more… | top users | synonyms

2
votes
0answers
10 views

Find a triangle in a graph represented as an adjacency list

I have a graph represented as an adjacency list. I need to find a triangle in this graph. A triangle is a triple of vertices u, ...
3
votes
0answers
36 views

Subset sum whose set contains only positive integers

I was trying to write a dynamic programming algorithm using a bottom up approach that solves the subset sum problem's version where the solution can be either an empty set and the initial set can only ...
5
votes
1answer
48 views

“Lights Off” puzzle in tkinter

I'm a newbie in Tkinter and I've managed to make the "Lights Off" puzzle using Tkinter with Python 3. The game starts by presenting 9 buttons arranged in a 3x3 matrix. The text of the button will be ...
8
votes
5answers
649 views

Reversing a number

I was working through a programming challenge I found on Reddit and it seemed easy enough: Find all numbers less than \$10^n\$ where the number and its reverse (the reverse of \$123\$ is \$321\$) ...
2
votes
1answer
37 views

Tic-Tac-Toe class written in Python

How well is this Tic Tac Toe code written? Where may I improve it? This is meant to be a platform for a machine learning algorithm. The code is written so any player may play first. Once a player ...
10
votes
1answer
145 views

Produce bitcoin private key from 31 playing cards

I've written some Python code to generate a random hexadecimal string using 31 playing cards drawn without replacement (so no card appears more than once). This is sufficient to provide more than 160 ...
3
votes
0answers
406 views

Real-time bitcoin data feed and storage using websocket framework

I'm trying to create data feed script for real time bitcoin data for OkCoin exchange using their websocket API (documentation) and a database manager for storing. There are two channels I am ...
3
votes
1answer
135 views

Python mnemonic ↔ hex conversion (Bitcoin BIP39) - follow-up

Original question: Python PBKDF2 using core modules I'm looking for commentary on the following code, which converts from a hex seed to mnemonic (12 word phrase), and vice versa. It's for Bitcoin ...
4
votes
1answer
26 views

Webscraping Bing wallpapers

I wanted to scrape all the wallpapers from the Bing wallpaper gallery. This was for personal use and to learn about webscraping. The gallery progressively gets images using javascript as the user ...
6
votes
3answers
100 views

Chi Square Independence Test for Two Pandas DF columns

I want to calculate the scipy.stats.chi2_contingency() for two columns of a pandas DataFrame. The data is categorical, like this: ...
6
votes
2answers
46 views

Encrypter - Double Vigenere Cipher in Python

I wrote this encrypter based on the idea of a Vigenere cipher, but instead of using only one key, it "makes" another key from the existing key. The length of the second key also depends on the ...
9
votes
5answers
1k views

Reversing a String in Python

I have a simple function that takes a string and reverses it: ...
4
votes
1answer
119 views

Binary search implementation [closed]

Is there a better way to implement a binary search than I am in my code? My function is taking two two lists - first_booth_voters and ...
5
votes
1answer
112 views

Simple hotel reservation system

This is a reservations software for hotel and restaurant management, allowing you to add and delete rooms, show available rooms, keep track of reservations etc. I am looking to trim my code a bit and ...
4
votes
2answers
59 views

Dataset and frequency list generation by looping over files

I have been told that it would be wise to split up my code into semantically useful blocks. I tried the following but I need feedback. What I already did: As you can see I create two .csv files, so ...
8
votes
2answers
90 views

'Mini Twitter' in Python 3

I've written a 'Mini Twitter' (that's what I've called it) in Python. It includes a text-based login screen and user panel where you can create Tweets, and change your username and password. Users' ...
7
votes
3answers
132 views

Slot Machine in Python

I have made this little program which allows you to play a slot machine: ...
4
votes
2answers
145 views

Generating frequency tables based on CSV dataset

I am working on a project which crunches plain text files (.lst). The name of the file names (fileName) are important because ...
2
votes
2answers
94 views

PyDOS Version 3.0

This is a follow up to the questions: PyDOS shell simulation and PyDOS: Version 2.0 Introducing PyDOS 3.0! With brand new features and improved code, this will blow your mind! New Features (This ...
15
votes
2answers
580 views

A turn based battle simulator (aka Pokémon)

I am embarking on the daunting journey of learning to program on my own two feet and have created a turn based battle simulator (think Pokémon). The idea came from here. It's very crude and could ...
3
votes
0answers
26 views

A simple backup script in python

Since rsync lacks compression and I'm not a big fan of rdiff I thought I try my own little backup script. Since I'm very ...
2
votes
0answers
20 views

guid to hex-string and back

I'm new to python and I'm trying to convert between Microsoft GUIDs and plain hex strings. My code (python 3) looks like this ...
8
votes
2answers
165 views

Parsing a list of single numbers and number ranges

I have input of a string containing a single number (like: \$3\$) or a range (like: \$1-5\$). Sample input, all together, looks like: "1-5,3,15-16", and sample ...
4
votes
1answer
60 views

Project Euler 91 (via HackerRank): Right triangles with integer coordinates

This is my code to solve HackerRank's version of Project Euler Problem 91: on an N × N grid, find the number of possible right triangles where one vertex is (0, 0) and the other two vertices are ...
8
votes
3answers
661 views

Computer guesses the user's number

After the feedback for my last script, I realized I should be using functions and trying to adhere to the style guide. I tried to do that here, though still very beginner. The rounding in Python ...
2
votes
0answers
27 views

Elo Rating Tracking Applet

I have a little applet that I wrote in Python and Tkinter, and I was wondering what a good way would be to make it public, or open source or whatever. I think it's quite fun. You can add players, ...
6
votes
2answers
2k views

Sherlock and The Beast

I have recently written the program for the Sherlock and The Beast' HackerRank challenge. That's working fine, but the problem is that it takes too much time if a big number is given as a input. I ...
1
vote
2answers
76 views

Army strength based on level and modifiers

Right so I was doing a quick project, and sought a quick way to finish one section of my Python code. I handed it in, but I'm well aware that it's bad code, but I was wondering if there was a good way ...
3
votes
1answer
40 views

Implement selection from array by 'random' or 'if/elif conditionals'

I'm working on some code examples in 'Automate the boring stuff in python...' to prepare for my first year of CS. I want to know if its better to use an array with random selection below or rather ...
7
votes
1answer
59 views

Small text-based RPG (v2)

This is my first text-based game I made. It's very small because I just learned Python and wanted to start small, and then code bigger programs. I added some stuff since the last time. Please give ...
5
votes
3answers
134 views

Small text-based RPG

This is my first text-based game I made. It's very small because I just learned Python and wanted to start small and then code bigger programs. Please comment on this. ...
8
votes
2answers
1k views

Text based fight game

I learned code about a week ago and I wanna hear some recommendations and stuff I could add to my code. This is a fight system I made for my text based game. Please tell me what I could do better. ...
8
votes
2answers
1k views

Guess a random number between 1 and 100

I want some recommendations or something I could add to the game. Please tell me what I could do better or what I did wrong. I made this during the time I learned Python. ...
2
votes
2answers
40 views

Merging two XMLs together in Python

I have these two XMLs that I want to merge together based on these conditions: If any of the element is more than 7 weeks old, it has to be deleted. If any of the element is newer with the same date ...
3
votes
1answer
202 views

PyQt5 GUI Application

I'd just like this PyQt5 code reviewed. I'm relatively new to classes and GUI programming, and wanted to make sure I wasn't doing anything too bad. If absolutely necessary, I can give you the other ...
4
votes
1answer
51 views

Simple Snake with pygame

I've been reading Dive Into Python and I needed to actually program something before I forget everything I learned. So, this is my first Python project (apart from trying the basics and playing with ...
3
votes
2answers
121 views

Function to find two prime numbers that sum up to a given even number

The Goldbach Conjecture asserts that any even number will be the sum of at least two prime numbers. I've created a function to find two prime numbers that add up to the number entered, but would like ...
1
vote
2answers
54 views

Compensating for typos in strings by removing spaces and making uppercase for comparison

I'm working with a database that has typos in the values. To compensate for them I've made a function called standardizer() which removes spaces and converts all ...
6
votes
1answer
76 views

Small Kivy application

I've written a small app using the kivy framework, which aims at reviewing your times tables. My major concern is about making this app easier to improve in the future. That is, how to organize the ...
3
votes
0answers
72 views

Matrix rotation algorithm - follow-up

In a response to this post I wrote a solution in Python. It passed all the test cases given, so I would like help making it more pythonic and reducing the almost repeated lines. Link to the source of ...
3
votes
1answer
110 views

Twirling cursor

I'm writing a twirling cursor, which is a cursor that twirls in place in the console. In Forth, this takes just 3 lines, whereas in Python3 I have this: ...
5
votes
3answers
96 views

Guess the bigger number out of two random integers

I want to make my code more efficient by instead of repeating my code again for level two, as the only change from level one to level two is the random numbers change from ...
5
votes
2answers
56 views

Writing a utility class for converting between datetime and timestamp

I'm writing an Python application that uses frequently datetime and Unix timestamp. I know Python is 'batteries included', however, I found that converting between datetime and timestamp in Python 2.6 ...
5
votes
2answers
523 views

Finding words of a given length only using given letters

It's a (simple) guesser for game where you need to find words of a given length only using given letters. I'd like to know if there's a more pythonic way to do things here. ...
6
votes
0answers
223 views

Matrix rotation algorithm

Problem Statement You are given a 2D matrix, a, of dimension \$MxN\$ and a positive integer \$R\$. You have to rotate the matrix R times and print the resultant matrix. Rotation should be in ...
4
votes
1answer
28 views

Simple local source control - Part 2

I've refactored the previous version of my local source control, and revised a few things. It's mostly the same, but there are a few minor differences, like the argument separator, one new command, ...
4
votes
2answers
87 views

Google's Python exercise about lists very different from the given solution

Disclaimer: Although I do believe that this is somewhat a code review, I'm not sure if this kind of question applies to the site; if not, please let me know and I'll delete it promptly. I found ...
2
votes
1answer
82 views

Listing movies for torrenting

Can I get some help on shortening the amount of code I have in this program? ...
1
vote
1answer
60 views

Card data extraction from file

I wrote a quick script and wanted some critique, as I don't get to practice my coding often, or even in one language I might make some idiomatic errors. The program works and runs \$145,555\$ entries ...
10
votes
2answers
226 views

Memoizing decorator that can retry

I have some tasks that I'd like to memoize because they connect to a rather slow network and have to wait for the data. Unfortunately this network can be a little finnicky and we get occasional ...