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
1 answer
20 views

Make a script to call pager duty's API and update on call

I made this script it works, I'm just looking for ways to make it better/reading to get better. ...
Alex Orbit's user avatar
1 vote
0 answers
29 views

Advent of Code Day 2 in Python

problem for day 2 Part 1 You're launched high into the atmosphere! The apex of your trajectory just barely reaches the surface of a large island floating in the sky. You gently land in a fluffy pile ...
code writer 3000's user avatar
0 votes
0 answers
17 views

DB Layer of a project management CLI

I am (re)writing a project management CLI and want to put it on a solid foundation concerning the database connections and testing. My focus was to build a DB class which is easy to test and could be ...
Koala's user avatar
  • 101
0 votes
0 answers
27 views

Simulating a Moving Average Process

I was studying stochastic processes and thought to independently simulate a moving average process. ...
insipidintegrator's user avatar
0 votes
0 answers
16 views

Managing users via SQLAlchemy DB model

I am currently in the process of writing a system application that will be operated by multiple users. This will require individual users to access the application while limiting access to those that ...
Michael's user avatar
  • 151
0 votes
0 answers
39 views

Is this iterative inorder traversal algorithm well-known?

I was concerned about the approach in Morris traversal algorithm and came up with simpler solution that uses parent pointers in nodes. The constraints were following: Time Complexity: O(n) Space ...
Max's user avatar
  • 1
-3 votes
0 answers
18 views

Raspi5 Throws "mmap of gpio registers failed" with pwm fan script [closed]

basically the title. the following code ...
sellem's user avatar
  • 1
2 votes
1 answer
32 views

Finding the longest path on a grid with obstacles from the top to the bottom

I have a rectangle of . (platforms) and # (obstacles). I can start at any platform in the top row and go to the left, right or ...
Aliaksei Badnarchuk's user avatar
-3 votes
0 answers
36 views

Printing more than one string variable with print in python [closed]

I am new to python and I having a hard time with a simple print of two strings. I am following some examples and I don't understand why it is giving me an error ...
some_math_guy's user avatar
6 votes
1 answer
74 views

Optimizing __getitem__ for a bioinformatics script in Python

I'm writing a script for a bioinformatics application in Python that iterates through several sequences looking for amino acids in specific positions to calculate their frequency in relation to a ...
Eduardo Menotti's user avatar
2 votes
0 answers
75 views

NLP pre-processing function optimization as it is extremely low on 92Mb data set

I have a data set that is of 300,000 rows approximately and two columns, each row contains a string, some might be larger than others. All in all, the data set in a ...
Louis's user avatar
  • 121
10 votes
4 answers
2k views

Number to text in Python

I'm kind of new to programming and I would need a suggestion whether there is a better way to solve this exercise. I need to write a function dict_of_numbers() that ...
fraber's user avatar
  • 101
0 votes
0 answers
34 views

Waiting time display app in Python

This application is for restaurant patrons to know how long they have to wait in line. We would like to design a more sophisticated GUI interface, but do not know how to go about it. Please let me ...
Mako's user avatar
  • 1
-3 votes
0 answers
30 views

Python check is an ip in ip network list [closed]

I try to check is an IP address in network list, but alway get False ...
wildarp's user avatar
1 vote
1 answer
65 views

Simple Tic-tac-toe in Python

I am a beginner programmer who coded a simple Tic-tac-toe in Python for practice. Any feedback, especially regarding best practices and tidying up the code, is appreciated. ...
smwt's user avatar
  • 103
1 vote
1 answer
83 views

Is it a correct way to read a file contents using paramiko (SSH, SFTP client)?

Is my implementation of _read_contents (3 lines) fine, or does it create a potential problem (e.g. passing part of an object that has to be destroyed, or a ...
Yulia V's user avatar
  • 633
2 votes
1 answer
55 views

Data structure to hold elements for script execution

I am building a solution to iterate over Python scripts in a folder and execute them. Each script will return a Pandas data-frame which needs to be saved as a Parquet file. The first stage is the data ...
Imtiaz's user avatar
  • 55
2 votes
2 answers
63 views

Dictionary additional function implementations

I've written a utility class BetterDict to help me on some of my other projects. I've implemented the &, ...
Linny's user avatar
  • 9,989
3 votes
1 answer
87 views

Pentomino solver in Python

When I was a child, I used to play Ubongo board game, recently I discovered Pentomino puzzle and I wanted to create a custom solver in python for it. Here is what I got: ...
Riomare's user avatar
  • 31
-2 votes
0 answers
14 views

Python tkinter program, assigning driver with sign in and log in [closed]

...
lai's user avatar
  • 1
0 votes
1 answer
63 views

HackerRank Algorithm Problem: Climbing the Leaderboard (Python)

Here is the Hackerrank problem which is related to dense ranking and below is my solution which didn't pass the time limit cases. Any better way to optimize this? ...
peternish's user avatar
0 votes
0 answers
22 views

cubic spline routine

I tried to implement the cubic spline algorithm in cython. I want to ask how I can make the code more efficient in terms of speed. Any suggestions or references ...
John's user avatar
  • 1
0 votes
1 answer
45 views

Python GUI Based IP location digger

Greetings. I'm a newbie python developer who just started using PyQt5 as his major GUI development tool. Because of this, I have started a side project known as NyvoAI, just for gaining more knowledge ...
KhodeNima's user avatar
  • 167
1 vote
0 answers
25 views

Making my code shine and pro: Python in Azure Function Retrieveing the Data From Rest API

The code retrieves the data from PBI API - it's my first one and I would like to learn how to make it pro. Here is the list of my questions: Can you please analyze 2 functions: GetReports and ...
user1956634's user avatar
1 vote
0 answers
41 views

Abstract Factory Config Loader [closed]

I've created a way to load a config file from JSON into an object and would like a review on the design pattern I used because the implementation feels a little "off" and I feel like there ...
Lafonz's user avatar
  • 11
3 votes
1 answer
84 views

Settings and global variables in one place

I have a configuration (YAML) file used across related modules. I also have a few additional variables to be accessed globally in my modules. I want to have them at one place (an instance of a class ...
Imtiaz's user avatar
  • 55
2 votes
2 answers
65 views

Dynamic python config reader

I am looking for a code review on the following code. Say I have a simple example class, something like the following: ...
Silverwilly's user avatar
3 votes
1 answer
187 views

Cleaning Yaml Data in Python

I'm working with a bunch of yaml files that are rather sloppy. This is outside of my control unfortunately, so I'm trying to clean up the data after the fact. My approach doesn't allow for nested ...
Jan van Wijk's user avatar
3 votes
2 answers
261 views

Trailing Digits

https://www.acmicpc.net/problem/23204 I've solved a programming challenge where you need to count the occurrences of a specific digit at the end of the product of multiples of a given number within a ...
qleoz12's user avatar
  • 141
1 vote
1 answer
89 views

Theme Toggle switch refactoring

I built a theme toggle switch function, and refactored it following an awesome suggestion in a previous answer. Before the refactoring the function looked like this: ...
atlvd's user avatar
  • 101
1 vote
2 answers
163 views

Split netmask or ip address

I've written a python function to split a netmask or an ip address. The code is about to become part of a custom router api. ...
Looser User's user avatar
3 votes
1 answer
59 views

Clock markings refactoring for enhancement opportunities

The given Python code snippet is for drawing clock markings. ...
atlvd's user avatar
  • 101
1 vote
5 answers
171 views

Finding a distinct triplet where the sum of the values is divisible by a given number

Given an array a and a number d, I want to count the number of distinct triplets (i,j,k) such that i<j<k and the sum aᵢ + aⱼ + aₖ is divisible by d. Example: when a is ...
Athul Raju's user avatar
0 votes
1 answer
56 views

Refactoring random time values list generator function

This function outputs random values in a list. Although I was happy to craft this solution from a more complex version, and it looks really cool to me, I wonder if it is an example of clean code. How ...
atlvd's user avatar
  • 101
0 votes
1 answer
30 views

Simplifying and enhancing readability in time angle calculation

Is the following Python code, which calculates hand angles based on current time, simple and readable? What alternative approaches can enhance simplicity and readability? Are there concise one-liner ...
atlvd's user avatar
  • 101
1 vote
0 answers
34 views

Telegram bot computing a heavy I/O task

Introduction I have a telegram bot based on aiogram framework. It does GPU intensive computations locally then user makes a request and outputs a text file after ...
Amir Suleymanov's user avatar
1 vote
1 answer
57 views

Password database: saving and loading encrypted files

I'm writing a password manager application, mostly with the goal of learning about proper handling of encryption. Here is my code responsible for encrypting/decrypting passwords and loading to/from ...
gazoh's user avatar
  • 3,004
-1 votes
1 answer
102 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
35 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
139 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
144 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
115 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
65 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
51 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
197 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
  • 101
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

1
2 3 4 5
307