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.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
103 views

HackerRank Project Euler 12 (Python) | Highly Divisible Triangular Numbers

I again share my Python code which didn't pass time limit test cases in the HackerRank contest of ProjectEuler. ...
peternish's user avatar
1 vote
1 answer
69 views

Project Euler 10(Python) | Summation of Primes

This is my Python3 code which solved the 10th problem of Project Euler. I haven't passed the last 2 time limit test cases. ...
peternish's user avatar
0 votes
0 answers
37 views

GUI Tic Tac Toe with unbeatable AI - styling

This question contains code of the updated version of my GUI Tic Tac Toe game, the code is about the styling and playing piece customization. It is related to: GUI Tic Tac Toe game with UNBEATABLE AI ...
Ξένη Γήινος's user avatar
2 votes
1 answer
144 views

GUI Tic Tac Toe game with UNBEATABLE AI players

This is an updated version of my Tic Tac Toe game with AI players, it is related to GUI Tic-Tac-Toe game with six AI players - part 1: the UI. But that question is more than two weeks old and no one ...
Ξένη Γήινος's user avatar
0 votes
2 answers
146 views

Python: Detect if a number is divisible by any number in a list

I am trying to filter steps such that it only contains numbers from 1 to step_size that aren't divisible by factors of ...
3StepsTooFar's user avatar
4 votes
2 answers
116 views

Python (API requests)

I'm somewhat new to python and I'm creating a script that requests to a certain API and then uses the response to populate a ...
Aldimar J's user avatar
0 votes
1 answer
70 views

Distance on a unit grid

I have a code that calculates Euclidean distance on a grid with border crossing or without that. ...
popcorn's user avatar
  • 103
5 votes
3 answers
2k views

Python strong password validator ( with unit test )

Lately, I was studying the concept of unit testing in python, so I have decided to write a imperative strong password validator ( checker ) and also attach a unit test to it. I would like to know if ...
KhodeNima's user avatar
  • 167
1 vote
0 answers
53 views

3ph 2l inverter simulation with SPWM

Here is a code for a simple model of three phase two level inverter with constant DC voltage source and three phase RL load. ...
ppinha's user avatar
  • 21
3 votes
1 answer
209 views

Project Euler 60: Prime Pair Sets

Project Euler Prime Pair Sets: The primes 3, 7, 109, and 673 are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 ...
peternish's user avatar
2 votes
1 answer
81 views

delete rows based on references to other tables in a mysql database?

I have a database with the following hierarchy. A dataset can have multiple scans (foreign key scan.id_dataset -> dataset.id) A scan can have multiple labels (<...
Roland Deschain's user avatar
1 vote
1 answer
52 views

Extending die roll simulations for complex data science tasks

I've developed a Python script that simulates die rolls and analyses the results. I'm now looking to extend and modify this code for more complex data science tasks and simulations. Is this code ...
atlvd's user avatar
  • 99
7 votes
2 answers
1k views

Convert 64-bit Gray code to integer

This algorithm encodes a 64 bit integer. As input I have a 64 bit integer a, for example: (a is a single 64 bit number,which I split in 8 bytes for readability) <...
tutizeri's user avatar
  • 173
4 votes
2 answers
850 views

Identifying unnecessary attributes in a Python class?

I have commented out two attributes (in random_number_guesser.py) which I believe are unnecessary. Am I correct in assuming that, because the code runs correctly without their implementation, they ...
dylanbobbyromero1's user avatar
10 votes
2 answers
769 views

Leap Year Calculator Using If Elif and Else Only

I'm taking the 100 Days of Code (Python) taught by Angela Yu on Udemy. There have been a few other questions revolving around this lesson but I can't find one who came up with my specific question so ...
AGM's user avatar
  • 103
1 vote
1 answer
86 views

Python Django image upload API with 6 fixed slots

I built an image upload API with Python Django. There are a fixed number of 6 slots, which can either be null or filled with something. There are two entities, Profile, which contains the six photos, ...
code writer 3000's user avatar
5 votes
1 answer
121 views

RNG Minigame In Python - Best Practices & Possible Improvements?

Recently, I got into programming with Python as a fun little side hobby. After watching a bunch of YouTube tutorials (to learn about IDE's, variables, etc.), I finally got to the point where I was ...
dylanbobbyromero1's user avatar
0 votes
0 answers
182 views

Value at Risk forecast generator

I am developing a code to compute Value at Risk (VaR) using various models (see below). Currently, I am looking to implement a rolling window approach over a dataset spanning 4,000 days, with each ...
Oscar's user avatar
  • 1
3 votes
4 answers
1k views

Merging sorted integer arrays (without duplicates)

I have written a Python function called merge_arrays which takes two lists and returns the new list merge without duplicate. The function works as expected, but my ...
XM01 - stands with Palestine's user avatar
1 vote
1 answer
180 views

Function that finds the exact number of times a string appears in a text

So I was tasked with providing a function that returns how many exact occurrences of attribute word appear in attribute text. The goal is for the function to be as fast as possible, and I managed to ...
Jules Raschilas's user avatar
1 vote
1 answer
54 views

Clock time validation app, cognitive exercise, minimal viable product

How to improve this code, how to make it accessible to get user feedback? This is a minimal clock time validation app. There is a clock face and the user is asked to validate the time the clock hands ...
atlvd's user avatar
  • 99
2 votes
1 answer
262 views

Test suite for population-count function, using random input

For the purpose of this discussion, I have the following function: ...
joseville's user avatar
  • 446
2 votes
2 answers
137 views

Python script to categorize download folder based on files

My Download habit is notorious and my download folder end up piled up with random downloads, I created a python script to maintain my download folder in windows upon running the script it moves files ...
SHANTNU CHAUBEY's user avatar
1 vote
1 answer
73 views

Pong using pygame module

I made a game in Python where you play Pong against an AI. As I am quite new to pygame, I would be grateful to hear any possible improvements. This is my code: ...
sbottingota's user avatar
1 vote
1 answer
84 views

Code that performs 2500 simulations by running a regression after randomly assigning 10 friends to each observation in a data took 20 days to run

I am running the following code to conduct a simulation. I have a dataset of around 100K observations. The simulation does the following: It randomly assign 10 "friends" to each observation ...
Joe's user avatar
  • 11
1 vote
0 answers
81 views

Electro-thermal simulation

I'm working on an electro-thermal simulation with variable parameters. Model require the calculation of all the electrical and thermal quantities at each time step, between a starting and ending time. ...
ppinha's user avatar
  • 21
1 vote
1 answer
181 views

Python3 currency abstract class (without the permission to be instantiated directly)

I'm a newbie python developer who accidentally studied the concept of Abstract classes and I found it pretty much helpful to implement due to the SOLID principles. At the very moment of testing and ...
KhodeNima's user avatar
  • 167
2 votes
0 answers
122 views

GUI Tic-Tac-Toe game with AI, part 3: control and logic

This is the last part of the series of posts about my GUI Tic Tac Toe game, the previous two question are GUI Tic-Tac-Toe game with six AI players - part 1: the UI and GUI Tic-Tac-Toe game with six AI ...
Ξένη Γήινος's user avatar
3 votes
1 answer
72 views

Logging activity traces with custom APIs

I've got this idea (based on experience) that logging plain messages isn't just enough to monitor an application so I built an abstraction layer on top of the built-in ...
t3chb0t's user avatar
  • 44.2k
2 votes
0 answers
52 views

GUI Tic-Tac-Toe game with six AI players - part 2: the styling

This question is part of a series of posts about my massive Tic Tac Toe game with AI players, the previous question is: GUI Tic-Tac-Toe game with six AI players - part 1: the UI. This question ...
Ξένη Γήινος's user avatar
5 votes
0 answers
226 views

GUI Tic-Tac-Toe game with six AI players - part 1: the UI

This is a huge project that I have worked on for the past few months, it contains 16 scripts, one of the scripts is used to analyze the other scripts. There are 111004 characters in all the script ...
Ξένη Γήινος's user avatar
1 vote
1 answer
80 views

ROM memory in SystemVerilog and cocotb

The Verilog module describes a ROM memory. An initialization file is needed for the INIT_FILE parameter. Below are Makefile, gtkwave.tcl to launch gtkwave, ...
Artem Shimko's user avatar
1 vote
1 answer
88 views

Two versions of user-specified exception filters that log a different message on match

I'd like to show you two versions of my two functions that support my logging tools. Their purpose is to log a different message (here abort) when an error occured ...
t3chb0t's user avatar
  • 44.2k
3 votes
1 answer
89 views

parsing json file with potential corrupted record and sorting by id to output first n lines - cleaner logic

messy json file is parsed and should output the N highest record IDs & scores by score in descending order, highest score first. the code works but i wonder if there is better readability, help me ...
ERJAN's user avatar
  • 887
3 votes
1 answer
155 views

Yet another CLI Hangman game

...with properly packaged/type-hinted code, automated testing, and no dependencies. Do note that this package requires Python 3.12 or later. Only pyproject.toml and ...
InSync's user avatar
  • 133
3 votes
1 answer
135 views

Python script that starts a video recording on a Raspberry Pi using a USB webcam

I’d love some critique, pointers or any improvement to my code. My project was mainly to record a video, through a Flask Application (online), then save it and display it on the Flask Application. ...
AlexanderKS27's user avatar
2 votes
1 answer
81 views

Agent based Dengue transmission simulation

I'm trying to implement the dynamics of Dengue transmission between mosquitoes and humans. I decided create two classes, one for the human population and another for the mosquitoes. Both are based on ...
Athansya's user avatar
0 votes
1 answer
29 views

Handling multiple socket communication in Python Client-Server application [closed]

I'm developing a client-server game application in Python. Here's the scenario: Clients connect to the server and register. After registration, all clients see a main menu. One client can initiate a ...
wallyyopp's user avatar
3 votes
1 answer
109 views

C$50 Finance - A Web App for Stock Portfolio Management

C$50 Finance is a web application built with Flask that allows users to manage their stock portfolios. It enables users to check real-time stock prices, view their portfolio values, and buy/sell ...
Harith's user avatar
  • 2,416
4 votes
2 answers
208 views

A Python terminal

This is the code for Pylect, a Python terminal I worked on a while ago which also caused my Desktop to get destroyed because of bad code. I use it infrequently but I would like a review for the code ...
The_AH's user avatar
  • 135
4 votes
2 answers
426 views

Continuously Monitoring ICY Stream Metadata (Title, Artist)

This script is called every minute, but I want it to run continuously instead of making that many requests to the radio station and I think that urllib.request can ...
x0tester0x's user avatar
3 votes
3 answers
131 views

Syntactic sugar for derived variables from Pandas DataFrame columns

Update: Okay, after trying to use this for a while, I think it's probably a bad idea. Please use (lambda x: x["a"] + x["b"])(df) if really ...
user1537366's user avatar
4 votes
1 answer
57 views

Random FASTA file generator

This is my code to generate a FASTA file containing multiple records with randomized DNA sequences with distinct length. I am looking for feedback on how to write this script better. ...
Supertech's user avatar
  • 141
0 votes
1 answer
51 views

Python 3.10+: an exploration of meta classes and subclasses through the lens of metric (SI) prefixes with subclass-able units and changeable bases

Problem Statement From the National Institute of Standards and Technology's Office of Weights and Measures, one can find a handy list of all the metric prefixes: e.g. Purpose Name Symbol Factor Name ...
SumNeuron's user avatar
  • 271
0 votes
0 answers
153 views

3D Game Engine Using Turtle

I am making a 3d Game Engine named t3d using Python's turtle module. Here is the code: ...
Tumo Konnin's user avatar
3 votes
1 answer
111 views

Catching the timed out Exception raised by the __init__ method of the class ftplib.FTP

Introduction I have written a Python class which uses the module ftplib. In this class I have created a private method called <...
User051209's user avatar
2 votes
1 answer
97 views

Metronome app with GUI

I have a working metronome app with a GUI, built using Python. I use an Android app called Pro Metronome which I like, and I wanted to build a simplified version of it as a project. My goal was to ...
dg0802's user avatar
  • 51
0 votes
2 answers
107 views

Optimize a Python code which indicates duplicated values in an excel file [closed]

I wrote this code to indicate duplicated values. It actually works but I hope to know if there's another possible solution to optimize this process. Thanks. ...
peternish's user avatar
3 votes
1 answer
116 views

yet another number of islands

i learn python and i am at beginner level in python TL`DR i did NOT read the other questions concerning this topic since i try to learn python and therefore need to do the same stoopid errors others ...
Martin Frank's user avatar
  • 2,786
4 votes
6 answers
631 views

Generate all lines from a file matching a given word list

I have a script - generator that accepts a file name or file object and a list of search words as input. The generator searches through the lines of the file and returns only those lines (the whole ...
zaelcovsky's user avatar