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
0 votes
0 answers
71 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
2 votes
1 answer
68 views

Generating Test Data with Python

Background: I'm a BI developer building a new dashboard for a client. They want to track performance for the week/month/year to date against the prior period. Unfortunately, I don't have direct access ...
DixieFlatline's user avatar
3 votes
1 answer
82 views

Simple Python MVC app for incrementing numbers using buttons

Intro: I am learning about the model view controller (MVC) architecture and I am looking for feedback from more experienced/knowledgeable people so I can check if my understanding is sound, and learn ...
dg0802's user avatar
  • 51
0 votes
2 answers
205 views

Printing the elements of a linked list [closed]

An absolute beginner here who is practising linked list problems in hackerrank. Stumbled upon this question which is categorised as easy. Given a pointer to the head node of the linked list, print ...
brucey's user avatar
  • 19
6 votes
2 answers
894 views

Script that tells you the amount of base required to neutralise acidic nootropic

Function Gives the mass needed of specific basic (pH above 7) substance in order to neutralise the pH of a specific acidic substance. ...
Nickotine's user avatar
  • 378
1 vote
0 answers
89 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
2 votes
0 answers
233 views

YouTube downloader application with GUI in Python

I would appreciate a review of my Python script that interacts with the YouTube API and downloads videos or audio from YouTube URLs or playlists. The script uses the pytube library for downloading and ...
Paichiwo's user avatar
  • 121
1 vote
2 answers
2k views

Simple Connection Pool for SQLite in Python

When I talk to people regarding connection pooling in SQLite most of them always laugh and say "You don't know about SQLite", "It is not a client server DB, and only overhead in ...
Swastik's user avatar
  • 13
2 votes
2 answers
187 views

User-defined Exceptions for Stack implementation

I am learning about user-defined exceptions in python and I have tried to incorporate them in a basic python implementation of a stack. Objects of Stack class ...
Ganesh Tata's user avatar
3 votes
2 answers
93 views

A Python class for handling mortality (and lapse) probabilities

I'm developing a model in Python which produces IFRS and SII balance sheets for a hypothetical life insurance company. To value the hypothetical company's insurance liabilities, I need to project the ...
M Smith's user avatar
  • 147
0 votes
0 answers
52 views

Exctracting features from each frame of a video and stacking all the frames' features at the end

I am working with videos. So, the input of my model has the shape of [batch_size,channels,frames,height,width]. So, my goal is to extract the the features from each frame separately using ResNet2D and ...
dtr43's user avatar
  • 51
9 votes
3 answers
2k views

Sorting array by odd numbers while leaving the even numbers in the same spots

The problem given was: "You will be given an array of numbers. You have to sort the odd numbers in ascending order while leaving the even numbers at their original positions." I developed a ...
Logan James's user avatar
3 votes
1 answer
37 views

A set of message broadcasters and a broadcast manager

I'm designing an application that will broadcast messages to various heterogeneous systems. Slack, JIRA, Database to name a few. Users can pass their various configurations using a yaml file. While ...
seve's user avatar
  • 33
6 votes
1 answer
127 views

basic Hartee-Fock program to compute the total energies and some properties of a molecule

I am trying to write a basic Hartee-Fock program that computes the total energies and some properties of a molecule given as an input. The code uses Cython to statically compile the computationally ...
Hemanth Haridas's user avatar
4 votes
1 answer
85 views

How can I make my mini-game simpler and more efficient?

I've recently started to learn Python and the task was to create a "hot or cold" game. They gave me the basic structure for the code and so far so good. But the bonus objective is to find a ...
Spirit's user avatar
  • 43
2 votes
2 answers
86 views

Aggregating psycopg2 Errors under a Context Manager

I have various functions which attempt to insert into a PostgreSQL database. In an attempt to remove redundancy for common errors that I was occurring I have created a context manager. Solution ...
Bob's user avatar
  • 139
6 votes
2 answers
813 views

Molecular simulation: Minimum Image Convention

Can you review the following code to check to see if the Minimum Image Convention is properly implemented? ...
user366312's user avatar
4 votes
3 answers
444 views

Python, loop trought in txt and print future login data

I would like my program to check what account I am currently logged in to (it works, I entered it (login4) in a variable for testing) and when it reaches the end of txt I want it to go back to the ...
Owneds's user avatar
  • 43
3 votes
2 answers
543 views

New York Times' Digits Game Solver

I wrote an algorithm to solve the New York Times' Puzzle: Digits. You could play the game here. The rules of the game are as follow: You were given 6 numbers and you could use simple operations (plus, ...
user274177's user avatar
5 votes
2 answers
717 views

Aggregating Python Exceptions

I wanted to be able to run a series of Python functions and capture every exception that happens. The solution uses a AggregateException class and tries to leverage Python scoping in order to ...
Bob's user avatar
  • 139
1 vote
1 answer
288 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
3 votes
1 answer
134 views

Implementing Model-View-Presenter in a console program

I'm designing a board game with my wife, and am writing a console based program that can track and analyze the statistics of playtests to see if the game is balanced, what the dominant strategies are, ...
Jan van Wijk's user avatar
1 vote
0 answers
43 views

Recurrent Neural Network loss is NAN

I am training a neural network to use approximately 600 features (4103rd to last column of a df) to predict approximately 4000 values (7th to 4102nd column of the same df). I have standardized the ...
Manas Garg's user avatar
4 votes
1 answer
148 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,989
0 votes
1 answer
90 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
203 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
  • 199
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
124 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
0 votes
0 answers
67 views

Optimizing Django / Wagtail Queries for a Blog

I'm using Django and Wagtail 5.x to build a blog. At this point, I'm trying to increase my understanding of query optimization and decrease the number of necessary db queries by implementing ...
user3605767's user avatar
1 vote
1 answer
81 views

Test whether every element in an array is equal to sum of subsequent elements

I want to ask how to improve this code. Is it well-written or should anything be changed? Please let me know. And is it a bad thing to use arguments to store some info, such as the argument value here?...
mcccuklev's user avatar
  • 139
1 vote
3 answers
142 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
1 vote
0 answers
93 views

Backtracking graph algorithms for a word puzzle in Python

Motivation Recently, Buzzfeed released a browser-based puzzle game called "Pyramid Scheme." It is available at the following link. The puzzle in an initial state looks like this: To solve ...
WilliamMorris's user avatar
2 votes
1 answer
99 views

Movie genre classification using machine learning

could you review my below code to train a machine learning model to classify movie genres? I've used the data from Kaggle ...
Thirupathi Thangavel's user avatar
2 votes
0 answers
120 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
2 votes
1 answer
84 views

Flag tukey outliers using python pandas groupby

I'm new to python and pandas. I would like to use pandas groupby() to flag values in a df that are outliers. I think I've got it working, but as I'm new to python, ...
Quentin's user avatar
  • 123
1 vote
3 answers
360 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
2 votes
1 answer
105 views

Find the list of combination (with repetition) given rank and number of items. (Lexicographic ordering)

The problem involves the fastest possible method to generate a list of combinations which repeats from all the possible combinations with repetition allowed. I know there needs to be a way to ...
Reptorian's user avatar
3 votes
1 answer
96 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
2 votes
2 answers
128 views

OOP tic-tac-toe

I have created my first personal project - tic tac toe game. It is my first time approaching code using Object-Oriented paradigm and I would like to get feedback on it and on aspects where I can ...
Ebrahim Al-Aghbari's user avatar
3 votes
0 answers
98 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 vote
0 answers
71 views

Fantasy football team builder [closed]

I'm very very new to coding. I'm trying to make an app that helps pick fantasy football players. It takes inputs from the user about what their preferences are and outputs a file that gives them a ...
Mally's user avatar
  • 19
2 votes
0 answers
68 views

Python script that generates images using Thue-Morse sequence

In mathematics, the Thue–Morse sequence, or Prouhet–Thue–Morse sequence, is the binary sequence (an infinite sequence of 0s and 1s) obtained by starting with 0 and successively appending the Boolean ...
Ξένη Γήινος's user avatar
4 votes
2 answers
184 views

"paper, rock, scissors" game

This is the first time I made a quick program, which is a game "paper, rock, scissors'. I am looking for any advice, and information if it is done in proper way or it is not. I did my code by ...
watsky's user avatar
  • 41
2 votes
1 answer
87 views

Raspberry Pi/PySimpleGUI based resistance test system

Hardware: Raspberry Pi 3B+, Elecrow touchscreen, DFR0660 Barcode Scanner, ADS1115 ADC I would like any bad practices/possible failure points pointed out specifically in the ...
Isaias_EE's user avatar
2 votes
1 answer
316 views

Find all permutations of string using recursion

Background: I am somewhat new to programming and only two weeks into learning Python. Currently trying to improve my understanding of recursion, which has been a tough concept for me to implement. ...
b-mitch's user avatar
  • 21
7 votes
1 answer
659 views

Remove hot-spots from picture without touching edges

In the picture below there are some regions which are very bright (i.e. more white). Some bright regions are wide and some are narrow or thin. The red box covers one such wide bright spot, and blue ...
S. M.'s user avatar
  • 173
3 votes
3 answers
186 views

Money class in python

I have recently created the Money class with a helper class Currency. What do you think about the following code? I created unit ...
lester's user avatar
  • 311
1 vote
0 answers
904 views

Streaming Parquet file in chunks for write operation

I am taking beginner steps into DE and was tinkering with writing an ingestion script which does the following tasks: Reads data from a source (in this case a remote parquet file) Writes it to local ...
av abhishiek's user avatar
2 votes
1 answer
76 views

Applying cointegration function from statsmodels on a large dataframe

I need to apply the coint function from the statsmodels library to 207 times series with 1397 points each, two by two. Currently, it takes between 35-40 minutes on my computer with an Intel 24 Cores ...
Begoodpy's user avatar
  • 125
1 vote
1 answer
113 views

Finding highly correlated variables in a dataframe by evaluating its correlation matrix's values

I read data from Excel into a Pandas DataFrame, so that every column represents a different variable, and every row represents a different sample. I made the function below to identify potential ...
Pimsel's user avatar
  • 25

1
3 4
5
6 7
307