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

learn more… | top users | synonyms

0
votes
0answers
7 views

Elo Rating Tracking Applet [on hold]

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, ...
1
vote
2answers
70 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
38 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
54 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
130 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

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. ...
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. ...
2
votes
2answers
39 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 ...
4
votes
1answer
45 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 ...
1
vote
2answers
53 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 ...
3
votes
2answers
99 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 ...
6
votes
1answer
66 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
52 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 ...
5
votes
3answers
89 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
52 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 ...
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, ...
2
votes
1answer
78 views

Listing movies for torrenting

Can I get some help on shortening the amount of code I have in this program? ...
4
votes
2answers
82 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 ...
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 ...
6
votes
0answers
187 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 ...
2
votes
1answer
59 views

Caesar cipher brute force

I have code that uses the brute force technique to find the message to a Caesar cipher. The program decrypts the message using different keys and then checks whether the resulting words are contained ...
8
votes
1answer
41 views

Simple local source control

I've written my own local "source control". Rather than using a commit-based system, when you're ready to release a version, you can run a command which will create a ...
4
votes
1answer
76 views

Using random to generate strings

I have code that reads from files of surnames, female and male names and randomly generates a name in the following format: lastname, male/female name. The files are in the following format: ...
1
vote
1answer
20 views

Transforming markdown files in folders into a documentation

I start coding a simple application: I transform markdown files in folders into documentation. My architecture is very flat. My code looks like a series of unit function called one after the other. ...
2
votes
1answer
69 views

Multithreaded Proxy Checker in Python

I've used PyLint to harden the styling according to PEP8 as much as I could but looking for feedback on anything I've missed. Also some questions below: Passing ...
10
votes
2answers
221 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 ...
4
votes
2answers
94 views

Implementation of Luhn Algorithm

I've implemented the well known Luhn Algorithm in Python. It's a simple one, so it's good for beginners. ...
6
votes
3answers
99 views

Slot Machine in Python

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

Alien Name Generator (using blocks of consonants and vowels)

This is my first script in Python, and I am looking for tips and constructive criticism about code style, whether there are more efficient ways of doing things, etc. (not as interested in tips about ...
7
votes
5answers
595 views

Random number guessing

Is there anything specifically bad here, or anything that I could improve? Wasted lines of code, things done in a more memory intensive way than it could be, etc. ...
7
votes
2answers
185 views

Solving 'decent numbers' that follow specific division rules

HackerRank Problem Statement I have to find the largest 'decent number' having N digits. A decent number has the following properties: 3, 5, or both as its ...
3
votes
2answers
294 views

Quadratic equation solver

I started Python 2-3 months ago, but I really haven't done much since then, just little things. Yesterday, I wrote this simple quadratic equation solver. You can give \$a, b\$ and \$c\$ any value, but ...
7
votes
1answer
139 views

Python class inheritance - using super() and __str__

I have been trying out some stuff using inheritance with classes in Python 3.4. In the code below, I use the super() call to return the ...
6
votes
1answer
51 views

String replacement using dictionaries

I've always been bothered by the fact that there weren't any built-in functions that could replace multiple substrings of a string in Python, so I created this function. Essentially, you supply it ...
7
votes
2answers
143 views

Skeleton for a text-based RPG

I'm new to python and created this small program. It's basically a skeleton for a simple text-based RPG. The program is one menu that allows you to: Create a Character View Character ...
10
votes
2answers
92 views

Processing command line parameters

This code works, but I'm curious what feedback you have about style and doing things in a more "pythonic" way. ...
6
votes
3answers
69 views

Cross-platform performance and statistical information script

My usual disclaimer, I'm new to Python and scripting and I'm still studying the PEP8 guide, so please forgive any huge failures with respect to syntax, formatting and style. I'm open to any ...
1
vote
0answers
38 views

Parsing span library

This is a Python library for efficiently tracking span information while parsing source code, and generating errors on those spans. I intend to use it in my rewrite of mypy's Python parser to add ...
6
votes
1answer
53 views

A tiny module for handling text updates

I call these text updates "Feeds". A Feed object has some basic attributes like its content string, how many lives it has and its priority in the queue. I haven't ...
6
votes
1answer
57 views

Cleaning old XML log files automatically

I have a piece of code that searches for XMLs in given folders, delete the ones older than X, zip the ones older than Y and delete zips older than X. It works perfectly but I have a terrible feeling ...
8
votes
3answers
252 views

Simple chat program

I've thrown together this simple chat program, and while it works. I think it could certainly use some improvement. Here's how it works. Obtain user input by removing all punctuation from the input ...
3
votes
1answer
16 views

Perfect Hash Family Non-Distinct t Columns Calculator

Perfect Hash Families (PHFs) are a widely studied combinatorial object. Essentially, they are 4-tuples (N; t, k, v), where the PHF is an ...
6
votes
2answers
60 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: ...
15
votes
1answer
179 views

Simple Morse code interpreter

This is a simple Morse code interpreter with a CLI. It's a naive table-lookup implementation, and uses my-py for type checking. It automatically detects the input (English or Morse) and converts ...
7
votes
1answer
98 views

Script to create a customized, efficient adblocking hosts file

I am writing a Python script that creates a customized, efficient adblocking hosts file. Basically it checks the user's DNS cache and sees if any entries there are listed in the popular hosts files. ...
11
votes
1answer
89 views

Creating a complex hierarchy for “Player Effects”

I'm coding a plugin for a game that has a Player class which has a boolean attribute frozen, which decides if the player is ...
9
votes
1answer
204 views

Soup of the day: best served during election season

Community moderator elections on the Stack Exchange network are really exciting. Alas, on the page of the primaries, I find it mildly annoying that candidates are randomly reordered on every page ...
8
votes
3answers
142 views

Dijkstra's algorithm without relaxation

I'm trying to implement Dijkstra's algorithm in Python, but the issue is that Python doesn't have support for key-based heaps out of the box, so applying relaxation step of the classical algorithm ...
11
votes
4answers
915 views

Simple game of Hangman

On my quest to become a master programmer I have created a simple game of Hangman, and so I thought I would upload it here and see how it could be refined. One question I had was my use of exception ...
5
votes
1answer
43 views

Script for creating custom hosts files

I wrote a basic Python script that consolidates and customizes several popular adblocking hosts files. I was interested in making it more efficient if possible, and I'd like to improve my style and ...