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

learn more… | top users | synonyms

3
votes
0answers
24 views

Mad Libs Generator

I created this Mad Libs generator, but I don't know how to get the value of the key "ans" into a format string tuple. I feel like it's not Pythonic and that it's very convoluted and over-complicated. ...
8
votes
1answer
395 views

Solving for Bananas

This code creates a problem for the user to solve (very simple problem) it will then check if the user has got it right and will say so. ...
-5
votes
0answers
10 views

Caesar Cipher Python 3: IndentationError? [on hold]

I am attempting to create a simple python script which will either encrypt or decrypt a phrase entered. Here is the source code: ...
3
votes
2answers
36 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....
-1
votes
0answers
13 views

python imports too verbose [on hold]

I am working on a python game and the import statements are too verbose and redundant. How can I make them lesser so? This is my directory tree: ...
2
votes
1answer
26 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 ...
0
votes
0answers
8 views

Python api for an existing Java API [on hold]

I am new to python and I have to design a Python API(version - 2.7) similar to an existing Java API Python version - 2.7 The Java API is as follows There is a Process interface ...
3
votes
0answers
29 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 ...
-1
votes
3answers
75 views

Shortest prime number generator we could come up with?

I worked with a friend on the following prime number generator. Our goal was to make it as short and as fast as possible. This is what we came up with: ...
6
votes
2answers
56 views

Crop black border of image using NumPy

Objective: Crop the image so only the number stays in the image Problem: Slow Performance I have code that crops an image. The image pixels are 0 or 255. There are no values between. The ...
5
votes
2answers
36 views

Splitting a CAN bus log in .asc format

I've written a quick script for a coworker to split a large CAN log into smaller chunks. (If you're not familiar with CAN, it's a communication protocol used by the ECUs in many cars.) I know where ...
-2
votes
0answers
27 views

Memory Game using Pygame and Python [on hold]

I am trying to create a memory game using python and pygame. There is one main problem. When I try to flip a card over it doesn't show the image, it just stays at the current state. I'm sure it's ...
6
votes
2answers
119 views

Python Lottery Game

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

Cython: Weighted Random Choice

I have a Cython function the takes a list of weights/probabilities (double) and returns a random index into the list. For example ...
5
votes
2answers
72 views

Function to check truth value of a specific statement

I want to check the truth of A + B - (A & B) == A | B for N-bit numbers. For example, here's a "truth" table for 2-bit numbers. (I know I'm taking liberty with ...
3
votes
1answer
61 views

Game map transitions edge cases

I am working on a simple 2-D game right now in Python. I was wondering if there was a better way than the below to write the game logic to check if the camera is near the edge of the player view, or ...
1
vote
1answer
47 views

Permutations part two

This is a follow up from this question. The goal is to make some function that can return the number of possible permutations with repetitions. As Gareth pointed out there is a nice formula for this ...
2
votes
1answer
45 views

Finding permutation from given lexicographical rank

I wrote the following little piece of Python code to take in some integer, and return a permutation that has that rank in the lexicographical ordering of permutations. While this works, I'm worried ...
3
votes
3answers
85 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 ...
10
votes
3answers
2k views

Counting permutations without repetitions for a number or a string

Can I make the following code faster with minor modifications? It times out on CodeWars website. ...
4
votes
1answer
28 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
49 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 ...
0
votes
1answer
43 views

Python editing lists and converting to a dictionary

After validation my errors list returns ...
7
votes
3answers
114 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
89 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 ...
2
votes
1answer
244 views

python: generate a 'diff' dictionary out of two nested dictionaries

I have written a function diff that takes two nested dictionaries and it computes a difference of their content (what is inside the list) returning a new dictionary....
0
votes
0answers
28 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 ...
2
votes
2answers
53 views

Plot heat map from csv file using numpy and matplotlib

There's a csv file with format: x0, y0, v00 x0, y1, v01 ... x1, y0 v10 ... And what I want to do is to plot a heat map, in which at location (x, y) the value v ...
4
votes
2answers
65 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. ...
2
votes
0answers
20 views

Search Indexer Transaction Safety

I am writing a search indexer for a site I built. It counts the number of times a word is used in a given story allowing one use of the word per chapter. I have also attempt to weight words in the ...
0
votes
1answer
31 views

Calculating and printing a credit card balance

I am working on a problem that simply calculates and prints the credit card balance. I hope this code can be improved/optimized a lot. I am from a Java background. If it was Java code, I would have ...
2
votes
0answers
53 views

Display a simulation using Tkinter

I wrote a module to simulate physics of 2D elastic balls and the community helped me to improve it on this post. Now I implemented a GUI using Tkinter to display the simulation in a window. I'm a ...
3
votes
1answer
73 views

HackerRank “Save Humanity”

The "Save Humanity" problem on Hackerrank asks us to: ... find all substrings in the patient DNA that either exactly matches the virus DNA, or has at most one mismatch. For example: ...
9
votes
1answer
234 views

A prefix notation calculator that asks about everything step by step

I made a prefix notation calculator. Prefix notation, aka Polish notation, is a form of notation for logic, arithmetic and algebra, like infix and postfix (reverse Polish) notation. The expression '+...
7
votes
2answers
81 views

Sum of prime factors of binomial coefficients over 9000!\${}\$

The problem I have lately been working Project Euler: 231: The prime factorisation of binomial coefficients The binomial coefficient \$ ^{10}C_3 = 120 \$. \$ 120 = 2^3 × 3 × 5 = 2 × 2 ...
1
vote
1answer
24 views

HackerRank “Lists” code

I completed the following exercise on HackerRank. My program is fed a list of commands, such as: ...
4
votes
3answers
565 views

Project Euler 10: find the sum of all the primes below two million

This is question #10 from Project Euler: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. I just started programming and read that a Sieve ...
2
votes
2answers
63 views

Merge sort Python implementation

Is this efficient? ...