# 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.

3,303 questions
Filter by
Sorted by
Tagged with
2answers
206 views

### Verhoeff check digit algorithm

A recent question on credit card validation here on Code Review, led me down a dark rabbit hole of check digit algorithms. I took a stop at the Verhoeff algorithm and tried to implement it myself. ...
1answer
64 views

### Find all concatenated words in a given list of words

This is a Leetcode problem - Given a list of words (without duplicates), write a program that returns all concatenated words in the given list of words. A concatenated word is defined as a ...
2answers
64 views

### Split an array into m subarrays such that the largest subarray sum is minimized

This is a Leetcode problem - Given an array which consists of non-negative integers and an integer m, you can split the array into ...
1answer
63 views

### Implementing Hangman using a State Pattern

I decided to implement a Hangman game using an object oriented State Pattern design. This is one of my first actual OOP as I normally write functional code. Code use: ...
2answers
262 views

### Python program to solve the “skyline problem”

This is a Leetcode problem - A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the ...
5answers
5k views

### Beginner's snake game using PyGame

I am a complete beginner when it comes to programming and writing games and this is my first ever game. I made it with python 3 using pygame library. I would ...
1answer
43 views

### Python simple type checking decorator

I'd like to know your opinions on this minimal type-checking decorator (with @ annotations) to make type checking of a method while debugging like : ...
1answer
87 views

### Python 3 simple external sort with heapq

I've implemented a minimal external sort of text file using heapq python module. On the few tests I did it seems to works well, but I would like to have some advice to have a cleaner and faster code. ...
2answers
48 views

### Target number sum finder

This is a Target number solution finder which I made with tkinter and is where the user enters a number they want and enters 4 other numbers to find the sum to make the number they want. This is a ...
4answers
94 views

### Python program to print all permutations of a string in lexicographic order using recursion

An assignment at school required me to print all permutations of a string in lexicographic or dictionary order. Here is my solution to the task - ...
2answers
2k views

### Yandex programming contest: Alarms

I've tried to solve this challenge about 4 hours during the contest, but all my attempts exceeded the time limit. I tried to solve it with min-heap, but can't pass all the tests. How it can be solved ...
1answer
70 views

### Python program to remove invalid parentheses

This is a Leetcode problem - Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note - The input string may contain ...
1answer
46 views

### Python program for Word Search II

This is a Leetcode problem - Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of a sequentially adjacent ...
1answer
53 views

### Python program to solve the “rod-cutting problem”

An assignment at school required me to write a program for this task: In the rod-cutting problem, we are given a rod of length n inches and a table of prices <...
0answers
89 views

### Python program to solve matrix-chain multiplication

An assignment at school required me to write a Python program for this task: In the matrix-chain multiplication problem, we are given a sequence of matrices ...
1answer
149 views

### A Python Blackjack terminal based game

I am looking for some feedback on my blackjack Python code. Any feedback is much appreciated. Docstring, code etc. Other than that, I need to test it, and I am not sure how to make this code more ...
0answers
85 views

### Daily coding problem 18: Maximums of k-sized windows

The challenge Given an array of integers and a number k, where 1 <= k <= length of the array, compute the maximum values of each subarray of length k. For example, given array = [10, 5, 2, 7, ...
1answer
55 views

### Daily Coding Challenge solution - day 21

The Challenge Given an array of time intervals (start, end) for classroom lectures (possibly overlapping), find the minimum number of rooms required. For example, given [(30, 75), (0, 50), (60, 150)],...
1answer
52 views

### Add-in for input() with validation

What do you think about this code? Do you have some advices and remarks for me about them? I have started learning python recently. ...
0answers
32 views

### Python3 - Cropping PDF files according to coordinates

I have a python script, that is performing OCR on PDF pages. I am trying to do so I can provide coordinates to the script - so it will only select the text within the provided coordinates ...
0answers
33 views

### Python: Exception handling in a logic gate

I'm learning about Python and am going through the OO-stage where I'm building a set of logic-gate classes. To make the logic more resilient, I only want the user to be able to enter a value of 0 or ...
2answers
104 views

### Python program to implement pow(x, n)

This is a Leetcode problem: Implement pow(x, n), which calculates x raised to the power n ...
2answers
305 views

### Python Chess Game

I'm developing chess in python, and I've decided to make everything text-based before creating a GUI because it'd be my first time doing the latter. I haven't got around to the actual gameplay, but I'...
1answer
116 views

### Python3 - Determing if a PDF is scanned or “searchable”

I am in a situation where I need to determine if a PDF file is either: Scanned Searchable (contain text) To do this, I am simply running the command pdffonts on ...
1answer
36 views

### Remove duplicated code from a Python function that gets data from and endpoint and, after manipulating it, returns the manipulated version [closed]

I have written the following function for a CLI tool, it works as expected but it also contains duplicated code. ...
1answer
43 views

### Simplify small pieces of code with Python/Django [closed]

I'm trying to make a code review for an external developer on my project. His code could be improved and I need your advices in order to know if my overwritten parts are better or not. Part 1 ...
2answers
70 views

### Python program for Jump game II

This is a Leetcode problem: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length ...
3answers
126 views

### Python program to find the first missing positive integer in a list

This is a Leetcode problem: Given an unsorted integer array, find the smallest missing positive integer. Note: Your algorithm should run in O(n) time and uses constant extra space. ...
5answers
2k views

### Count Even Digits In Number

I was asked to complete this CodeStepByStep problem. Here's a quick summary: Write a function named count_even_digits that accepts two integers as parameters ...
1answer
76 views

### Python program to find the substring with concatenation of all words

This is a Leetcode problem: You are given a string, S, and a list of words, L that are all of the same lengths. Find all starting indices of substring(s) in S that is a concatenation of each word ...
1answer
64 views

### TickeTron for booking seating

I have written a program that simulates a TickeTron and allows the user to book seating in a virtual audience. The virtual audience is read in from a text file which will be included below. The ...
2answers
87 views

### 3D metrics for segmentation evaluation

I am new to programming and I am trying to develop a machine learning approach for image segmentation (https://en.wikipedia.org/wiki/Image_segmentation) and here I want to evaluate the predicted (...
5answers
1k views

### Python program to find Armstrong numbers in a certain range

I have written a Python program to check for Armstrong numbers in a certain range. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the ...
3answers
344 views

### Python program for a simple calculator

I have written a program for a simple calculator that can add, subtract, multiply and divide using functions. Here is my code: ...
8answers
4k views

### Python program to take in two strings and print the larger string

I have written a Python program to take in two strings and print the larger of the two strings. Here is my code - ...
1answer
67 views

### Python program to find the factorial of a number using recursion

A factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 5 (denoted as <...
0answers
44 views

### Countdown number game solution v2 using itertools

I recently posted a solution for the numbers game on the Countdown TV show using a recursive technique. For those unfarmiliar with the rules… A fixed set of numbers (usually 6) are chosen at random ...
2answers
70 views

### Countdown - word solver

Here is my Countdown word solver. This code aims to find all possible permutations of any length of a given input (which in the Countdown words game is any random assortment of letters). It then ...
4answers
224 views

### Find all the factors of a given number

The most basic code(i guess so) to find all the factors of a number Note:factors include 1 and the number itself Here's the code: ...
1answer
72 views

### Get all possible subsets from a set of distinct integers using OOP

An assignment at school required me to write a program for this task: Create a class and define two methods in the class. Method ...
1answer
110 views

### Script to download images from Reddit

I wrote this script to download images from Reddit. I would like to hear from others on how can I improve this script. ...
1answer
99 views

### Python program to find the subarray with maximum sum

An assignment at school required me to write a program for this task using Kadane's algorithm (explained here): Define the function find_max_subarray that ...
8answers
3k views

### Python program for fibonacci sequence using a recursive function

A Fibonacci sequence is the integer sequence of 0, 1, 1, 2, 3, 5, 8..... The first two terms are 0 and ...
1answer
44 views

### Find filenames with 4 digits which are not divisible by 20 and delete them

I have a set of files in folder my_dir, which is not the folder where my Python script resides. Sample content of my_dir: ...
2answers
55 views

### Grouping a Pandas Dataframe by two parameters

I have a .csv file of 8k+ rows which looks like this: ...
2answers
61 views

### Solve quadratic equation in standard form

The first code I ever wrote, sorry that the prints are in German. I tried to do some code improvements myself but well whenever I do I fail. Hopefully somebody can help me improve my coding skills. <...
1answer
1k views

### Python script to extract text from PDF with images

I have the following Python script. The purpose of the script is to extract text from PDFs. I use textract for that because soon I realized there is no easy way to check if a page contains an image or ...
1answer
77 views

### Simple integration of async and tkinter in Python

I've been a fan of coroutines and asynchronous programming for a while, and I recently took a trip down memory lane to when I was using Python's tkinter module for ...
0answers
168 views

### Population dynamic simulation on biological information maintenance 2

This question is the follow-up to this previous question. Background Using this simulation I investigate a system in which enzymes proliferate in cells. During the replications of enzymes, ...
3answers
109 views

### Calculate the nth Fibonacci number, mod m

I was trying to output F(n) mod m to find the remainder of Fibonacci number, where F(n) could be a very big number: ...