Questions tagged [python-3.x]

Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 3 interpreter only. Do not mix this tag with the python-2.x tag.

Filter by
Sorted by
Tagged with
4
votes
1answer
996 views

Base64 encoder and decoder

I'd like to have some feedback on this small snippet I wrote to implement a base64 encoder and decoder. Specifically, I'm not sure I'm handling padding in the best way possible. ...
7
votes
2answers
2k views

Beginning Python guessing game

I am new to Python (and coding in general) and after about a week of reading "Thinking Like a Computer Scientist: Learning with Python" I decided to try and build a version the classic "guessing game"....
5
votes
1answer
182 views

Extracting time duration in the session from 30 million rows

I am looking for making my code faster. I am working on yoochoose recsys 2015 dataset.. and trying to perform some transformations.. [recsys2015], it has got 30 million plus rows of data. The goal of ...
0
votes
1answer
213 views

Image-processing filters using decorator pattern in Python 3

The goal of the following short Python 3 program is to improve my understanding of the decorator design pattern. Therefore, I would be mostly interested about feedback on this aspect, i.e. whether ...
1
vote
3answers
192 views

Finds all the prime numbers up to n using a strange pattern

Here's an odd pattern I found for sieving out composite numbers to find primes. I wrote it myself, originally thinking I made an indexing error, but it turned out to work after removing squares. <...
9
votes
3answers
1k views

Save the Prisoner

A jail has prisoners, and each prisoner has a unique id number, S, ranging from 1 to N. There are M sweets that must be distributed to the prisoners. The jailer decides the fairest way to do this is ...
10
votes
1answer
5k views

Find installed and available Windows Updates

I have a function that uses Windows Update Agent (WUA) API through COM using the win32com.client module, part of pywin32 package for retrieving the installed and the available (not yet installed) ...
4
votes
0answers
562 views

Tkinter RSS feed

I am creating a GUI program using Tkinter wherein I utilise the Feedparser module. My code executes in the following way: Get the stock ticker to insert into the URL from the user. Parse the URL and ...
5
votes
1answer
5k views

Session handling using Python Requests client

I'm using this code to login to an experiment login system created by me for this purpose. ...
8
votes
1answer
100 views

Mail utility class for use with Flask

...
3
votes
0answers
141 views

Deque class using typing module

I wanted to make a class for type hinting that the result of a function is a homogenous deque. ...
11
votes
2answers
5k views

Python IBAN validation

I wrote a simple Python IBAN validator, which I'd like some reviews on. INTRO Quoting from wikipedia, we know that: The International Bank Account Number (IBAN) is an internationally agreed ...
8
votes
1answer
518 views

Multiplication or addition of decimals or integers for prehighschool; non deterministic testing

I'm creating a simple android app for pre-highschool students which teaches the very basics of addition or multiplication of integers or decimals. The part of the program in this question is aimed ...
21
votes
3answers
45k views

BFS Implementation in Python 3

...
4
votes
2answers
519 views

Export data from Python to spreadsheet

I have written the following code to export to data to a spreadsheet with this result: Please let me know how to improve it. ...
4
votes
1answer
47 views

condensing a list of lists with 'description' lines in Python

I have a long list of data pulled in from a csv file that has comments / descriptions scattered throughout the document. I'd like to collapse the descriptions into the last element of each row of data,...
0
votes
1answer
70 views

How to avoid carrying around a lock with my variable when multiple threads instantiation in Python?

I created an application using multiple threads defined in multiple class files which read and write into a "shared variable" (a dictionary). To ensure thread-safety, I am using a Lock, and I pass it ...
1
vote
2answers
3k views

Python Search file for string and read into list

This function of my program is searching a file that is formatted as first_name last_name rate hours: John Smith 25 80 Mary Johnson 15.5 60.0 ... With one space ...
8
votes
2answers
588 views

A brainfuck interpreter in python 3

I've been writing a brainfuck interpreter in python 3. It's nothing serious, but I'm trying to make it as good as possible (considering program structure, user experience and etc) for my own learning ...
2
votes
2answers
484 views

Memoizing decorator with retries - now with backoff added! (Part 3)

A continuation of Memoizing decorator with retries, part 2, and related to https://codereview.stackexchange.com/a/133493/47529. I liked my decorator before, but especially in my original use case of a ...
12
votes
4answers
5k views

Inserting robot moves into an SQLite3 database

I'm just wondering if you would consider this to be safe from SQL injection. A peculiarity of my program is I need to dynamically access table names depending on my scenario. This is not for ...
4
votes
2answers
94 views

Determine the ratio of the contents of a pot to the (metal) volume of of the pot

This is my first Python project, so: create a pot with dimensions (radius, thickness of wall, thickness of base, height), fill it with food (to a specific height). Determine the ratio between the ...
3
votes
1answer
5k views

Hackerrank New Year Chaos

My code given below will produce the correct output but it tends to take way too much time with larger data thus timing out for some of the test cases. I've linked to the problem description here: ...
3
votes
1answer
223 views

Tracking orders efficiently using a Python class

I've written a Ledger class for a daemon process, which is supposed to keep track of an exchange's orderbook. My main concern is the way I keep track of the orders -...
8
votes
3answers
338 views

Python Tabletop Initiative Tracker

I wrote my first Python program today after working through a few books. I decided to build a group initiative tracker for our D&D group and was hoping to get some feedback. Critiques on code ...
2
votes
1answer
388 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 ...
8
votes
2answers
19k 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
vote
1answer
49 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
4answers
2k 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
1k 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 ...
14
votes
5answers
33k 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
377 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 ...
1
vote
1answer
180 views

Python Decimal to Binary converter (without using bin() or output formatting)

There is no input validation for this, but that aside, I would appreciate it if anyone could help me improve the logic of this script. ...
2
votes
1answer
558 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. ...
5
votes
3answers
281 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 ...
9
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
3k 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 ...
2
votes
1answer
1k views

Python binary to decimal converter (without using built-ins)

Any ideas how I could improve this? I already know that there is no checking for anything other than a 1, so you can enter a 2 ...
1
vote
1answer
5k 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: ...
3
votes
1answer
3k 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! ...
8
votes
2answers
7k 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
4answers
10k 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 ...
4
votes
2answers
501 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
550 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
121 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
12k views

Python Lottery Game

How could I improve this code or make it more efficient? ...
2
votes
3answers
758 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 ...
5
votes
1answer
61 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. ...
11
votes
1answer
335 views

Pillow-based basic GUI library for an LCD

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 ...
8
votes
3answers
303 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 ...

1
63 64
65
66 67
81