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

learn more… | top users | synonyms (1)

1
vote
1answer
27 views

Disk Partition type lookup table

The following code I am using to lookup the description based on a "Partition Type" in either a string, an integer or hex value. By calling parttype(parttype) in ...
6
votes
2answers
566 views

Creating a questionnaire

Im making a Python program. It is basically a questionnaire and I was just wondering if there is a shorter way of doing this as at the moment I'm writing out all of the questions in separate functions....
-1
votes
0answers
21 views
0
votes
1answer
21 views

Renames file-name references inside files in a directory

The filenames.txt contains all the names of the files that you want to change in a given directory. It is generated by: ...
-4
votes
0answers
25 views

Python text game [on hold]

Im a complete noob and started today, i watched some videos about how to make a simple text game but doesnt seem to make it happen. When i run the shell it says missing paranthesis around print, i ...
1
vote
2answers
29 views

Points and segments solution

Task: Given a set of points on a line and a set of segments on a line. The goal is to compute, for each point, the number of segments that contain this point. Input Format The first ...
2
votes
1answer
38 views

Encoding a list of frequencies as WAV audio

This code gets a list of signals with predefined frequency from struc.num I need to encode it to wave format, so i use this code. This works, but i dont sure it is a correct decision to encode like ...
9
votes
5answers
2k views

“Guess the Number” game in Python

I have been using Python 3 to learn programming, and this is a very basic task, but I want to gain good programming patterns/habits at the very beginning. The program will first randomly generate a ...
2
votes
2answers
24 views

__str__ method for a tic-tac-toe board

I am making my first object-oriented program in python and I am having trouble with the __str__ part of Board() class. I want it ...
2
votes
1answer
23 views

Exponential backoff generator

Exponential backoff in the context of various networking protocols looks something like this: When a collision first occurs, send a “Jamming signal” to prevent further data being sent. ...
3
votes
0answers
18 views

Memoizing decorator with retries, part 2

A while ago I asked this question Memoizing decorator that can retry and then promptly forgot about it. I more recently saw Python decorator for retrying w/exponential backoff and wanted to add ...
8
votes
2answers
1k views

Reduce number of operations to get one array value

I can't wrap my head around that. There seem to be a lot of redundancy, and even if it is not called called more than ten times in the main loop, I still find it hard to swallow that it loops through ...
4
votes
2answers
71 views

Compare files by name in two folders A and B and delete duplicates from folder A

I wrote my very first Python program to answer a Super User question. I'm wondering how the application can be rewritten to make it as pythonic as possible. Unit test ...
1
vote
1answer
51 views

Sum over selected numpy.ndarray column and write to a file

I am trying to write the sum of selected NumPy array column and write to a file. The following code snippet is working fine: ...
2
votes
1answer
77 views

Prime number checker in Python 3 - follow-up

I have updated my code from the last time it got reviewed. If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated! ...
4
votes
2answers
33 views

Invoicing Program Python

This is my invoicing program I made for myself to keep track of purchases people made from me. (Yes I know eBay does this for me but I wanted to see what I could make.) Basically it can search the ...
-4
votes
0answers
26 views

can someone helpe me imporve my code or fix it? [closed]

I need to reach 1,000,000 and for some reason it doesn't give me the output for 1,000,000, it crashes. I don't know what i am doing wrong. Every time i put a small number like 500 it would take a ...
2
votes
3answers
46 views

HackerRank “Nested Lists” Code

I completed the "Nested Lists" challenge on HackerRank, and would love any feedback on my code. My program is fed text with the number of students in a classroom, the name of a student, and their ...
-5
votes
0answers
19 views

Caesar Cipher Python 3: IndentationError? [closed]

I am attempting to create a simple python script which will either encrypt or decrypt a phrase entered. Here is the source code: ...
4
votes
2answers
62 views

Prime number calculator in Python 3.4.1

I have only been coding for a short time and I have written these two functions and am looking to optimise them. If anyone could point out things that could be done better it would be much appreciated....
4
votes
1answer
43 views

First text-based adventure game

I'm sure there are better ways to code this. I spent a lot of time re-working the code to get it as clean as possible. I would appreciate any input on what I could change to have the program run ...
3
votes
1answer
52 views

Code to create and check a numeric password

I am very new to coding and I have created this relatively simple code to do with my basic knowledge of the language. However I have had to do with some unwanted code including shutting it down if ...
6
votes
2answers
135 views

Python Lottery Game

How could I improve this code or make it more efficient? ...
3
votes
3answers
97 views

Removing numbering gaps in a series of filenames

I've recently started programming and have been working through some problems such as the one below: Write a program that finds all files with a given prefix, such as spam001.txt, spam002.txt, and so ...
4
votes
1answer
29 views

SOXXY: a daemon stated IRC client project

This script is basically a proxy service; except it doesn't require an active client connection. In fact it expects the client connection to connect before, and disconnect after every transaction. ...
8
votes
1answer
52 views

Basic GUI library for an LCD built (nearly) from scratch

I am working with an LCD screen and an RPi. The library I use sends 1-bit images to the screen, so I wrote this library based on Pillow to help developing the on-screen GUI. I am playing with the ...
7
votes
3answers
130 views

Unicode Chess PvP with Move Validation

Main Purpose This script allows two players to play chess on a virtual chessboard printed on the screen by making use of the Unicode chess characters. Visual appearence ...
7
votes
1answer
96 views

Project hotel reservation in Python with OOP and multithreading

I have to create a project in Python 3 for a university exam. The project involves the use of object-oriented programming and the use of multithreading. My project is based on the simulation of ...
0
votes
0answers
34 views

Python console chat on Windows

I'm currently learning Python and I have to build a simple labyrinth game that we play in the console on the network. I dig a bit into Python basic network programming and I decided to build a simple ...
4
votes
2answers
68 views

Python lazy dict with iterator in constructor

This question began as an off-topic answer to this question, but the code here serves a different goal. I wrote the following class for the purpose of populating a dict on demand from an iterator. ...
1
vote
1answer
27 views

HackerRank “Lists” code

I completed the following exercise on HackerRank. My program is fed a list of commands, such as: ...
14
votes
2answers
212 views

Year 0: Instruction Follower

Having played Human Resource Machine for over a day, and wanting to improve my interpreting / tokenizer skills, I made a Human Resource Machine interpreter. For those that do not know, so if you do ...
4
votes
0answers
63 views

Youtube playlist saver with Google API

I have a problem with Youtube videos being deleted from my big playlist and not knowing which videos got removed. So, I decided to write a Python script to save certain information(title etc.) about ...
5
votes
2answers
121 views

Creating a simple 52-card data structure for Blackjack in Python

I am fairly new to Python so I am trying to learn more about its conventions and ways to make my codes more efficient. I am making a Blackjack game and so far have this class that draws, organizes, ...
4
votes
2answers
264 views

Simple meter simulator

I've created a simple python meter simulator which connects to a serial port (in my case COM1) listens on the serial port and takes actions based on what it ...
1
vote
1answer
37 views

Income Simulation programifier

http://pastebin.com/7UqD0gwF I'm looking for serious feedback on my first serious program. This is a program to calculate PvZ income over time of sunflowers and sunshrooms on nighttime pool levels. ...
1
vote
2answers
64 views

HackerRank 'Bot Saves Princess 2'

I submitted the following Python 3 code for this HackerRank challenge. Given an n × n grid with an m and a p in random cells of ...
0
votes
1answer
39 views

Iteratively extending a list

Is there a way to collapse multiple_get into as few lines as possible? ...
4
votes
0answers
94 views

Optimizing the calculation of complex exponential numbers using OpenMP

I am trying to create a function that can either beat numexpr or perform comparably for the vectorized mathematical operation ...
5
votes
1answer
49 views

Reddit mirror encryption challenge

While reviewing Encryption using a mirror field, I decided to write my own solution from scratch. The challenge, from Reddit's /r/dailyprogrammer, is to implement a monoalphabetic substitution cipher ...
1
vote
1answer
35 views

Making a quiz in python and I need help making the code more concise when I add longer lists of questions

I'm a complete beginner at python and I know I'm probably approaching this the wrong way but I've tried making a quiz and can't work out how to make it more concise and work with longer lists of ...
5
votes
3answers
105 views

HackerRank “Bot Saves Princess” beginner code

I submitted the following Python 3 code for this HackerRank challenge. Given an n × n grid with an m in the center and a p in ...
6
votes
3answers
84 views

Pomodoro Timer in Python

I wrote a simple Pomodoro Timer in Python 3: ...
4
votes
1answer
78 views

Sanitizing words extracted from text files and writing them to a database

This code reads text files from some path, tokenizes, removes stop words, lowercases, removes punctuation and numbers, then writes the result to a database. ...
4
votes
2answers
149 views

Script to print weather report from OpenWeatherMap API

This script prints the weather (fetching the information from a public API). If anyone could review my code and answer my question about code structure and how should I code in the right way, I ...
1
vote
1answer
67 views

Project Euler 54: Winning Poker Hand

The problem can be found here. The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first ...
3
votes
2answers
91 views

War card game using classes

I would like some feedback to the code I wrote for the card game War. While programming it, I wanted to make classes that I could easily use for other card games too (hence why some functions are ...
3
votes
3answers
58 views

Project Euler Problem 11: largest product of 4 adjacent numbers

I am a fairly beginner-level programmer, and I have been working through the Project Euler Puzzles. I am currently on Problem #11, which asks to find the largest product of four consecutive numbers (...
3
votes
1answer
59 views

Hackerrank Funny String python solution

"Funny String" problem from Hackerrank Suppose you have a String, \$S\$ of length \$N\$ indexed from \$0\$ to \$N-1\$. You also have some String, \$R\$, that is the reverse of \$S\$, where \$S\$ ...
1
vote
2answers
25 views

Settings Model to read multiple settings files and writes to one

I am writing a Model to read, write and store settings. I think my code is pretty good, but I am not 100% sure. Any advice on how I could possibly improve it is welcome. ...