Questions tagged [python]
Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.
15,587 questions
1
vote
1
answer
5
views
Substitute patterns with values from lists
I was looking at a Stack Overflow question and got somewhat carried away with improving the solution, well beyond the scope of that question.
In summary, we have a string such as
...
1
vote
2
answers
70
views
ASCII-based Lightweight Browser in Python with Clippy-Style Helper [duplicate]
Note that this is the original version which has not been formatted to comply to PEP-8 and contains an error in the code. Please visit the updated version instead to post answers, comments and/or cast ...
4
votes
2
answers
641
views
Unicode-based platformer game in Python (Updated)
I already asked this question, but the script I provided was not compliant to PEP-8, so I rewrote the script for better readability.
I'm making a platformer game called Uni where this small character ...
3
votes
5
answers
613
views
List folders with size
This code below aim to listing all folders in one directory and get size of each in byte. It uses only pathlib module for that.
...
2
votes
3
answers
1k
views
LeetCode 3542: Minimum Operations to Convert All Elements to Zero
I am working on this LeetCode problem where I have to count the minimum number of operations to make all elements in an array equal to zero 3542. Minimum Operations to Convert All Elements to Zero
...
4
votes
1
answer
226
views
Use z3py to solve one logic constraint puzzle
I decided to practice by modeling some simple, hand-solvable problems using z3py. Below is an example:
...
8
votes
3
answers
124
views
Test to ensure CGI can be invoked on a local server
I am writing tests for legacy software which has a dependency on CGI scripts on a remote machine.
Mocking the dependency would entail modifying the code under test, which is a thing I cannot do at the ...
8
votes
3
answers
2k
views
Replacement for "make" in Python
I'm working on a replacement for make written in Python. Instead of a Makefile, you create a Wormfile.py. This file gets imported dynamically and a Context object ...
6
votes
3
answers
974
views
Moving ball simulation within a donut
How do I optimise my code more?
The goal is to have my code work with more than 200 moving balls, but that takes forever right now and doesn't look smooth at all. Furthermore, I can't get the sizing ...
11
votes
5
answers
911
views
Python program that iterates over audio files with a progress bar interface
I have a utility that updates, transcodes and renames audio files. Previously I used a function that simply yielded every file that was a good match (based on file extension).
As some tasks can take ...
2
votes
2
answers
105
views
Heat Diffusion Equation Solver
I'm implementing a numerical solver for the 1D diffusion (heat) equation using an iterative method. The initial temperature distribution is a Gaussian profile, which should theoretically smooth out ...
2
votes
2
answers
112
views
Calculation of liquid propellant nozzles
I'm calculating the injectors, and I've added the complete calculation code and tested it using pytest. Can you suggest a better way to structure the code so that I ...
9
votes
4
answers
806
views
Find the smallest semiprime satisfying a bunch of conditions
The purpose of this code is to find the smallest semiprime \$s = a b\$ satisfying a bunch of conditions stated in the Math.SE question What is the smallest "prime" semiprime?. The conditions ...
4
votes
4
answers
1k
views
7
votes
3
answers
463
views
Polars crosstable between two variables in a dataframe
I wrote a function that computes the cross tabulation between two variables in a polars dataframe.
It supports absolute values, row percentages, column percentages ...
4
votes
1
answer
222
views
CSV TimeSheet Calculator
This program takes in a CSV timesheet for my current job, groups the hours worked by employee then outputs it to a txt file. I used a simple GUI with tkinter and ...
8
votes
4
answers
1k
views
Python implementation of core fundamentals to calculate math arithmetic
This program takes a user input to choose which calculation method they'd like to use, then uses a separate module and the math library to perform said calculation.
I'd like some feedback as to how ...
8
votes
3
answers
756
views
Github actions workflow for release and publishing to PyPI using uv
I have a Github actions workflow that on pushing a tag does the following for a python package:
Creates a Github release using the tag version.
Publishes the package to PyPI.
The package build and ...
5
votes
2
answers
282
views
5
votes
2
answers
409
views
Wordsearch Generator (Tracking Success/Failure)
I'm creating a wordsearch generator that takes a list of words and outputs a 10x10 grid (2D array) of letters. This is roughly how it works:
loop over words
use boolean ...
4
votes
1
answer
365
views
Half-hexagon neighbour identification under (novel) hierarchical hexagonal grid
Context & Background
Please let me remind you that this project may involve original research; it is important to remember that all content on this site is subject to CC BY-SA 4.0. It is a breach ...
4
votes
2
answers
200
views
Class for validating code in different Conda environments with PyTorch
I wrote the Validator class. In the project, the presented code is located at the path ".../validator/init.py". It is needed for testing code in different virtual Conda environments, in the ...
4
votes
1
answer
212
views
Telegram userbot in python
I have a telegram userbot, monitoring certain group topic and answering certain messages.
I want it to be faster than human, now it's surprisingly not.
But I need to speed up its reaction, any tips?
<...
8
votes
2
answers
1k
views
Python OOP game of Hangman
I am currently learning object oriented programming in Python.
I attempted writing an OOP program for hangman, and while the program is functional, I just ended up writing a very long class method. ...
8
votes
3
answers
491
views
Interpolating based on non-diagonal neighboring values
I have a comma-separated value (CSV) file as input, and I am supposed to interpolate all missing (nan) values based on neighboring non-diagonal values.
The CSV ...