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
0answers
15 views

Enigma Implementation in 3 languages: C# pro, JAVA and Python newbie [closed]

I want to learn Java and Python, so I ported a C# Enigma implementation of mine. All of them have UnitTests and are running. I'm looking for a review, telling me, where I don't know best practices, ...
3
votes
1answer
27 views

Basic calculator using break statements to control the logic

Below is a simple calculator program in which I'm using break statements to control the logic. I was wondering if this is overkill on the break statements or is it OK. ...
11
votes
3answers
283 views

OOP Hangman Game

My daughter and I are trying to teach ourselves Python and OOP. We wrote a hangman game, and we'd really appreciate some feedback. Are we heading in the right direction? How could we improve it? ...
0
votes
0answers
5 views

argfile: read/write stdio or specified file depending on command line argument

A unix convention is to use - as a placeholder for stdin/stdout in command lines, e.g. gcc -x c - to compile stdin as C. I often ...
-3
votes
0answers
19 views

How convert data from float to integer in python [closed]

I need to convert data from float to integer in the following code and in the "num" command ...
0
votes
0answers
16 views

Implement the XOR Gate using a 2-layer neural net with just Python & NumPy

I wrote a 2-layer neural net with just Python & NumPy to implement the XOR Gate, here is the code ...
-1
votes
2answers
37 views

Should you follow the style convention in python with old libraries? [closed]

From the PEP8 "Function names should be lowercase, with words separated by underscores as necessary to improve readability." Then we have popular libraries like matplotlib with arguments i.e....
2
votes
1answer
290 views

Python - Two Number Sum (time and space complexity)

I'm solving the classic problem of finding two numbers from an array that sum to a given value. Can anybody please check whether my analysis of time and space complexity is correct on this one? ...
2
votes
1answer
34 views

Maze generator for Dungeons and Dragons

Hello everyone I was told to post this here instead of StackOverFlow. I am using PyAutoGUI currently as this was the best tools I could manage to find to use a piece of software that has no native ...
0
votes
1answer
34 views

A port scanner made in python

I don't know how to use classes and i think its meant to be used here to avoid repetition of functions but i can be completely wrong, i am a student who keeps learning bit by bit. Please can you take ...
3
votes
1answer
245 views

Reducing the amount of duplicated code (python) - cricket matches [closed]

I'm a beginner and self taught and just want to see if there are neater ways of doing what I am doing, or whether there are bits of code that are poorly written. I think Lines 100-204 are the most ...
1
vote
1answer
35 views

Python program to accept user input for Pandas methods

I know this is a weird program but I am trying to learn how to write Python programs. This program will accept user input, starting by having the user specify a file path then continuously looping ...
4
votes
1answer
65 views

Python multi-connection downloader

This is a simple Python multi-connection downloader primarily using requests, mmap and threads, it downloads a single file using 32 concurrent connections, slices the download using range parameter, ...
4
votes
2answers
78 views

Bisection, linear recurrences and even Fibonacci numbers

So this code is yet another attempt at solving the second Project Euler problem to improve my handling of Python. The purpose of the code is to solve the problem below Each new term in the Fibonacci ...
2
votes
3answers
92 views

A better way to extract COVID data from Worldometers

I was trying to fetch some data (daily new cases and daily new deaths) from Worldometers and I came up with this: ...
-6
votes
0answers
46 views

Why is this python code bad? [closed]

I had an interview a few days ago in python and the last question was: say what's wrong with the archive function in terms of scalability, architecture, security. The purpose of this function is to ...
-1
votes
0answers
31 views

Infinite map in Ursina

I made an infinite map in Ursina. The game freezes for a second every time I press 'l' to generate a new area. My Face code: ...
1
vote
0answers
26 views

The best tensorflow neural net I got so far for iris dataset

Compared to my another post Logistic Regression for non linearly separable data which uses one-layer net, i.e. Logistic Regression to classify the iris data set, this post is to discuss the tensorflow ...
0
votes
1answer
23 views

Logistic Regression for non linearly separable data

Iris Data Set consists of three classes in which versicolor and virginica are not linearly separable from each other. I constructed a subset for these two classes, here is the code ...
2
votes
1answer
56 views

Weighted draw/raffle (biased towards undrawn)

I tried to implement a weighted draw. The idea of which is, you can have disproportionate probabilities of drawing different items. In this particular case, I want to cumulatively bias the probability ...
1
vote
1answer
70 views

Data storage and processing in Python

I have a piece of code that downloads acupuncture data from Wikipedia and consolidates it into an acupoint, meridian and extraordinary meridian dictionary stored as .pkl files in the working directory....
0
votes
0answers
41 views

Simulate rolling dice game - Recursive [closed]

I want to write a program that simulates a game as follows: A random number between 1 and 2 is generated to determine which player starts the game (player1 or player2). The player who starts the game ...
0
votes
0answers
23 views

Adding page iteration capability to Requests scraper

I am trying to build on @Reinderien's answer to my previous question over here to add page iteration functionality to the code: ...
0
votes
0answers
10 views

Bayesian ranking of fanfics with python and sqlite

I've done a script to sort fanfics by the bayesian average of views and rating. I've used views because it took much longer to scrape the dlp website for reviews. I leave all the code so that it works....
4
votes
1answer
62 views

Tkinter Sticky Notes

Currently I am creating an app in Tkinter that creates, displays, and saves sticky notes. I am new to python so I keep trying to rewrite my classes so I have my code more organized but every time I ...
0
votes
0answers
60 views

Simple Inverted Index made in python

So I made an inverted index following a tutorial online and was wondering if I can improve it by implementing one or more algorithms or reduce code or maybe make the processing files faster. I am ...
0
votes
0answers
28 views

Creating bins from 3D points (large dataset) with python for faster processing [closed]

I am trying to make a 3D plot of a galaxy catalog and have a large amount of x,y,z coordinates and data value (w4) stored in seperate hdf5 files, all of a total size of 5.5 GB (500 MB x 11 files). I ...
1
vote
0answers
46 views

Remove duplicated multiline blocks in text

A quick and dirty line-based approach for detecting duplicated text blocks. Did not find any references as to what (deterministic) algorithms are there for detecting duplicated text blocks, so went ...
3
votes
1answer
133 views

Scraping a dynamic website with Scrapy (or Requests) and Selenium

I am trying to use Scrapy for one of the sites I've scraped before using Selenium over here. Because the search field for this site is dynamically generated and requires the user to hover the cursor ...
1
vote
1answer
16 views

Adding websocket functionality to send live data from a Python script. Any edge-cases or unexpected consequences to beware of?

The original purpose of this script was saving data to a local file, which is still the primary purpose. Since I may only obtain one copy of a data stream (not this particular Coinbase one; it's just ...
1
vote
0answers
31 views

Thread-safe running mean and variance

In one of my personal python libraries I have a custom class used for computing the running average and variance of a stream of numbers: ...
-2
votes
0answers
33 views

Python3 Simple Calculator- Pytest [closed]

I have had to create a simple calculator that takes in two values and adds, subtracts, multiply or divides the values. I have completed this, below, but now I need to do a pytest on it and I am at a ...
0
votes
0answers
8 views

Scraping Kayak with Selenium: issues in clicking travel boxes [closed]

I am trying to scrape data from the following link for an academic project: https://www.kayak.it/explore/MIL-anywhere/20210801,20210801 I need to open each single travel box, then click the button '...
3
votes
1answer
172 views

Fantasy Football (Soccer) Simulation

What my program does My program does simulation for fantasy football. Its inputs are teams and teams results in a particular match and its outputs are how many points each team earned in each match ...
0
votes
2answers
95 views

Interview: Drug Analyzer class

the introduction is this: You are a member of a biotechnology programming team that is responsible for creating a system for lab technicians, which will assist them with drug analysis. Your goal is ...
2
votes
2answers
53 views

Pandas split column into multiple: performance improvement

Aim of the Code: The aim of the function I'm working on is to take a particular column from a DataFrame that contains multiple <tag><content> pairs in ...
5
votes
1answer
24 views

Rainbow Trails Video Effect

This is an effect to augment juggling videos: The goal of this effect is to add a rainbow trail to a video using a tracked set of points. Link to source video Link to source data Link to complete ...
3
votes
1answer
38 views

Dynamically indexing numpy array

I want to create a function that takes a numpy array, an axis and an index of that axis and returns the array with the index on the specified axis fixed. What I thought is to create a string that ...
3
votes
1answer
45 views

remote file follow using python

I've created an on-demand class that can be initiated to collected any new data written to file from start_recording call until ...
0
votes
0answers
50 views

Logistic Regression for MNIST binary classification

I wrote a Logistic Regression model that classifies MNIST digits. I used tensorflow & keras only for import the dataset. ...
2
votes
1answer
28 views

Virtual keyboard for typing Latin with diacritics characters

I'm developing a notepad with virtual keyboard integration. The purpose is to provide a free tool to type the Latin letters with diacritics. I came this far, but due my limitation and lack of coding ...
5
votes
2answers
438 views

Given an array of integers, return the minimum required increment to make each element unique

The task is: Given an array of integers, return the minimum required increment to make each element unique. Sample Input 1: [3, 4, 2, 2, 6] Sample Output 1: 3 (One of the 2s should be incremented to ...
3
votes
1answer
38 views

Data API with Influx-DB and FastAPI

I'm fairly new to time series databases in general and Influx in particular. My objective is to build a simple and general-use API that will allow me to write and read data from an Influx Database. I ...
8
votes
3answers
1k views

Find the number of trailing zeros in factorial

I am trying to find the "Number of trailing zeros of N!" (N factorial). In the python code I am trying to find the factorial first and then the number of trailing zeros. However, I am ...
4
votes
1answer
37 views

GUI that reads data and generates/ saves charts

I have a program that uses pandas to read csv files and then generates and saves graphical charts. I have been trying to follow the SOLID principles so I have tried to seperate responsibilities. So ...
2
votes
2answers
76 views

Employee directory

I had this as a project last school year and decided to try and optimize it. I'm curious to see how much I have learned; is this a good way of doing it? ...
0
votes
0answers
39 views

Vectorized code to find the position and length of runs of 1s in a bit matrix

I'm trying to write something like an adjusted run-length encoding for row-wise bit matrices. Specifically I want to "collapse" runs of 1s into the number of 1s in that run while maintaining ...
1
vote
1answer
37 views

Archiving MongoDB data to S3, with retryable steps

I have a python script to archive some data (export from mongo to a local json file and then upload it to s3) Is there a better way to implement/improve the current flow? Each step should be be ...
9
votes
4answers
3k views

First non-repeating Character, with a single loop in Python

I recently tried to solve the first non-repeating character problem. Please tell me if my solution is valid. I'm aiming for O(n) with a single loop. My thinking is, it would be easy to tell you what ...

1
2 3 4 5
278