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
1 vote
0 answers
37 views

Convolution to reduce popcorn noise in black and white video

I have a black & white video as a tensor with the shape [Time, Width, Height] with popcorn noise and I would like to reduce the noise by naively convolving along the time dimension. Using a ...
Seanny123's user avatar
  • 1,517
2 votes
0 answers
47 views

Python tic-tac-toe using tkinter

I recently made this tic-tac-toe program using tkinter, but I am quite new to tkinter, so I would be grateful for tips on how to improve the program. (Note that the actual tic-tac-toe logic is being ...
sbottingota's user avatar
2 votes
0 answers
149 views

Can the k-index in either of the two individual locations be used to predict the estimated kp-index?

The k-index measures the condition of the magnetosphere. It is usually averaged over three hour, so each day has 8 measurements. The planetary k-index (kp-index) is an average of the measures taken ...
S. M.'s user avatar
  • 201
8 votes
3 answers
2k views

Algorithm "sort except zero"

Task: Sort the integers in sequence in sequence. But the position of zeros should not be changed. Input: List of integers (int). Output: List or another Iterable (tuple, generator, iterator) of ...
Глеб's user avatar
  • 183
1 vote
1 answer
82 views

CPU emulator written in python (Adjustable Microcode!)

I've designed and implemented a CPU architecture in one day. Of key architectural details: Processor is supposed to support updatable microcode, Architecture extensions and Is designed to be ...
ToAskOrNotToAsk's user avatar
4 votes
2 answers
121 views

NumPy script to convert BGR to HSL and back

This is a NumPy script that converts BGR arrays to HSL arrays and back, without using OpenCV. Input and output values are arrays of 3 dimensions with values ranging from 0 to 1, the shape of the ...
Ξένη Γήινος's user avatar
1 vote
2 answers
72 views

2D Point subclass of complex builtin

I'm writing a pure-python geometry tool for technical drawings / computational geometry (not a solver, as a solver has to work with constraints). I've already mentioned a previous version on code ...
ToAskOrNotToAsk's user avatar
0 votes
2 answers
139 views

Generate random password from a list of allowed characters

The code itself is a random password generator which is encapsulated. The other question about this code is whether it should be encapsulated on its main function. Or is it enough to exist in its own ...
KhodeNima's user avatar
5 votes
1 answer
61 views

Metaclass Wrapping Builtin to Enforce Subclass Type

This metaclass utility is written to make subclassing builtins easier, such as int, str, and most importantly, ...
ToAskOrNotToAsk's user avatar
0 votes
0 answers
29 views

Synchronisation access to a shared class in Python server with async/await

Last week I wrote a simple server on FastApi to run ML model to classify a text on Chinese (split text on separate words). When I had clarified work of this model with API, it became time to confirm ...
Gleichmut's user avatar
  • 121
-1 votes
2 answers
50 views

Application install code- Need to remove Nested Loops and make code more compact and readable. Code installs application and its version as per req

This code installs the application, according to the type of application selected like alpha, beta, and released, also it checks for latest version in each type. ...
Rohan's user avatar
  • 19
10 votes
3 answers
1k views

Here is a Tic Tac Toe game in Python using functions

I am a new programmer, learning from youtube and other sites I can get my hands on. The assignment was clear. Create a Tic Tac Toe game using functions as much as possible and where needed. I am ...
LindaJuniordev's user avatar
2 votes
2 answers
770 views

How can I get my CPU Utilization Down? PYGAME PROJECT

I get 25% CPU usage on this simple project. I hope it's okay if I just post the whole thing. It probably something to do with the rendering code. It's definitely the project though, my fans get loud, ...
DizzyDazzo12's user avatar
2 votes
1 answer
65 views

Count the Streaks in a coin flip and display the number of Head vs Tail Streaks

Like title says programs shows you the number of streaks and how many of each. Is there anyway to break this down. Feels like it's too many variables. ...
Big_Port's user avatar
0 votes
0 answers
20 views

convolutional neural network in python

I am new to python, so the challenges for me currently are: Clear, simple code, trying to follow standard practices Useful comments, Use types (for better understanding of input/output relationships.)...
Minsky's user avatar
  • 239
2 votes
1 answer
76 views

Randomly rotate an image through right angles

I'm new to Python, and coming from Typescript, I tried to include types, but it's not obvious sometimes. Currently this is the way I type objects: Write own simple types Import type from a library ...
Minsky's user avatar
  • 239
1 vote
2 answers
75 views

Python 3.10+ deconstructing an over engineered solution to better understand how metaclasses work with properties, static methods, and classmethods

TL;DR This question examines an over-engineered example of python metaclasses and dataclasses to create a LiteralEnum (for validating a stringly-typed keyword ...
SumNeuron's user avatar
  • 271
4 votes
1 answer
133 views

Very simple Flappy 'Bird' game - First project in Python

I am a beginner in Python. This is my first project in Python (that I tried to complete). There is a grey square that acts as the Flappy 'Bird' with green obstacles spawning with random gap sizes. The ...
A Random Dude's user avatar
3 votes
1 answer
306 views

Python function to find the count of digits of numerals in base n up to a given limit

This is a simple exercise to find the count of digits of all numerals in a given base up to a given limit (not including the limit), I wrote it to determine the ratio of bytes saved when the numbers ...
Ξένη Γήινος's user avatar
1 vote
0 answers
85 views

YouTube to LBRY Video Uploader - V0.1.0

I have developed a Python script that allows users to upload videos from YouTube to LBRY. The script also performs video post-processing and database operations. I would like to request a code review ...
Walid Mujahid وليد مجاهد's user avatar
4 votes
1 answer
271 views

Python IP geolocation script

These are two Python scripts I wrote to convert a GIGANTIC text file of over 100MiB in size (the current version is 152.735MiB) to an SQLite3 database to use for geolocation, and the script that ...
Ξένη Γήινος's user avatar
3 votes
2 answers
113 views

Middle-outwards alternating iterator

I have a use-case where I want to iterate from the middle of an array outwards, so I generate a list of indices as follows: ...
Seanny123's user avatar
  • 1,517
1 vote
0 answers
64 views

"Sticky Note" App

The code below is a Sticky Note App. ...
Shraddha Shetty's user avatar
0 votes
2 answers
108 views

Python script that makes generalized Ulam spirals

This is a Python script I wrote to generate generalized Ulam spirals. I call the spirals generated by my code Ulamish spirals, they are one dimensional polylines that cross all two dimensional lattice ...
Ξένη Γήινος's user avatar
0 votes
1 answer
28 views

Re-write of PDF invoices from user input, decoupling of Invoice from FPDF class

Following on from this post and taking on board some of the suggestions, what follows is a re-write of the original python code. It's also just a rewrite of some of the functionality, this code only ...
Lozminda's user avatar
0 votes
1 answer
95 views

Pythonic and mypy compatible way to map str to Enum

my goal is to have a user input a string that is checked to be valid - by defining a dict of allowed strings - and mapped to another string to be stored in a list. Another function is supposed to map ...
user2606240's user avatar
2 votes
1 answer
86 views

Password recognition with cryptography

Since I only just learnt about this, I wanted some advice on better practices I can use when it comes to cryptography. Still learning python and hoping I can get this 'hashing' and 'salting' thing in ...
Beginner's user avatar
  • 189
2 votes
2 answers
86 views

Increasing writing speed to file inside a for-loop for large files

I have a .csv file containing 100 millions records, I would to create multiple files from this file, after certain condition satisfied in each line, I came to this code below, but it is slow, I think, ...
Khaled's user avatar
  • 309
1 vote
1 answer
33 views

Counting distance between kmer instances in a sequence

I want to calculate the distance between k-mers instances in a long sequence (words of length k, bigrams, trigrams, etc. In bioinformatics the are called k-mers). I developed this code that look for ...
Paulo Sergio Schlogl's user avatar
2 votes
1 answer
86 views

Pomodoro Work Timer with GUI

My first actual code using GUI. Based off a class I took. Code criticism much appreciated. (I was all over the place with this one) Resources Picture: Sound: https://www.freesoundslibrary.com/success-...
Beginner's user avatar
  • 189
5 votes
3 answers
383 views

Python script to split overlapping ranges, version 4

This is the fourth iteration of a Python script I wrote that splits overlapping ranges, and this is the fastest version I have wrote so far, and also a version that works for all inputs. I have done ...
Ξένη Γήινος's user avatar
2 votes
1 answer
69 views

Leetcode 137: Single Number II -- python bit operations

I solved LeetCode 137 in C++. TLDR of the problem: array of numbers, nums is given; all numbers appear 3 times, except one which appear only once. Find the number ...
Mircea's user avatar
  • 322
-2 votes
2 answers
121 views

Applying the __add__ operator on all fields of a Python object

I have a class for which I want to overload __add__ to mean adding all fields between obj1 and ...
Alexis Drakopoulos's user avatar
1 vote
1 answer
47 views

Change unit-test structure to avoid try/except/finally clause

I have 10 or 20 tests with the same structure which I would like to improve. The test itself is nested within a try/except/finally clause to make sure that some of ...
Mathieu's user avatar
  • 211
0 votes
0 answers
48 views

Pygame Texture Ray Caster

Recently I have been attempting to develop a ray caster in python pygame. I managed to get it to work fairly efficiently when using basic colors, but when I altered the program to use textures instead,...
JohnSmith's user avatar
1 vote
1 answer
101 views

Calculate the cost of Biryani lessons

Problem: According to a recent survey, Biryani is the most ordered food. Chef wants to learn how to make world-class Biryani from a MasterChef. The chef will be required to attend the MasterChef's ...
kvk30's user avatar
  • 113
1 vote
0 answers
86 views

Python script that maps natural numbers to lattices in a spiral-like manner

This is a Python script that maps natural numbers to lattice points in a spiral like manner. It maps all natural numbers to all points with integer coordinates, and it produces a list of coordinates ...
Ξένη Γήινος's user avatar
0 votes
3 answers
54 views

Calculate length of continuous gaps

So, I have a list with some nan values, out of which some are continuous. e.g, list = [1, 2, 3, np.nan, np.nan, 6, 7, np.nan, 9, np.nan,np.nan,np.nan, 12] For some necessary reason, I'd want to get ...
Ranjan Kumar Sahu's user avatar
1 vote
1 answer
138 views

Python 3 script that draws animals using basic functions

I'm new to Python and only started learning a couple months ago. I get that this is a really unsophisticated code and I'm a newbie, but are there any blatant issues with it that I can improve upon? I ...
CommercialGrape's user avatar
4 votes
1 answer
138 views

AutoComplete-Esque Tree

I've written a tree data structure that takes in input from the user, and stores the each letter based on the previous letter in the text. I'm not sure what this is called, but the closest I can find ...
Linny's user avatar
  • 9,948
0 votes
1 answer
86 views

A practice program to manipulate a database table using dependency injection [closed]

I am learning dependency injection and trying to use this pattern on practice. I am trying to write simple program where the user can write something to database, delete row and clear all rows from db....
Денис Шпак's user avatar
1 vote
3 answers
141 views

Decorator to validate that Python function arguments are positive

I have a list of functions whose parameters in the signature should be validated with the same criteria each time. ...
SeF's user avatar
  • 209
5 votes
4 answers
2k views

Automate the boring stuff with python - Character picture grid

Character Picture Grid Say you have a list of lists where each value in the inner lists is a one-character string, like this: ...
Jarne Vercruysse's user avatar
2 votes
3 answers
118 views

Automate the boring stuff with python - Comma Code v2

This is the second version of code reviewed earlier. Comma Code Say you have a list value like this: spam = ['apples', 'bananas', 'tofu', 'cats'] Write a function ...
Jarne Vercruysse's user avatar
1 vote
3 answers
119 views

Automate the boring stuff with python - Comma Code

Comma Code Say you have a list value like this: spam = ['apples', 'bananas', 'tofu', 'cats'] Write a function that takes a list value as an argument and returns a ...
Jarne Vercruysse's user avatar
2 votes
0 answers
81 views

Minimal Chess Web GUI with Flask

Being a big chess fan, I finally started developing my own chess tool, however I'm already quite dissatisfied with where it's going... folder structure: ...
Mantas Kandratavičius's user avatar
1 vote
3 answers
158 views

Automate the boring stuff with python - The Collatz Sequence

The Collatz Sequence Write a function named collatz() that has one parameter named number. If ...
Jarne Vercruysse's user avatar
6 votes
3 answers
1k views

Automate the boring stuff with python - Guess the number

...
Jarne Vercruysse's user avatar
3 votes
1 answer
84 views

Terminal Based Blackjack

This is my attempt at a terminal based blackjack game. Currently, the game does not support betting, although I intend to add it in the future. I would very much appreciate general feedback, but I am ...
Katie Grace Porter's user avatar
3 votes
0 answers
80 views

Image generator using prime numbers in polar coordinates

Related This is a Python script that generates images using prime numbers up to a given positive integer, it generates prime numbers using the Sieve of Eratosthenes with some rudimentary Wheel ...
Ξένη Γήινος's user avatar

1
2 3 4 5
107