All Questions
Tagged with python python-3.x
4,610
questions
1
vote
0answers
7 views
Displaying validation messages for an input form
I'm trying to capture all input fields in a form (i.e. sign_up.html) & validating them - if one of them is null or empty then it should show a validation message. I've done it but I'm looking for ...
0
votes
0answers
12 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 ...
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:
...
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 ...
0
votes
0answers
42 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 ...
4
votes
1answer
63 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 ...
-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
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 ...
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 ...
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 ...
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
1answer
141 views
Python case insensitive dictionary [closed]
This is a Python case insensitive dictionary that is ordered and has integer indexes for the keys and values.
I just wrote it today.
It is ordered because I am using Python 3.9.6 and plain ...
1
vote
1answer
85 views
6
votes
1answer
369 views
Python code for eliminating options for random intergers as they get picked
My goal is to write code that picks several random numbers from a range without repeating any previously chosen numbers.
I figured out a functional solution for my problem but it seems very bulky and ...
1
vote
0answers
76 views
Python case insensitive three level nested dictionary
This is a custom case insensitive nested dictionary class created by me, its main usage is to populate QTreeWidget and keep track of said QTreeWidget, the main incentive behind this class is to ...
5
votes
0answers
45 views
Thread Art Generation that Creates Embroidery Files
I have made a thread art generator that creates thread patterns from images. Mine is a bit different as it outputs an embroidery file (It embroiders quite nicely, though the settings need a lot of ...
4
votes
2answers
47 views
Simple enemy movement simulation on Tkinter
Kind of a noob at Python here, and this is one of my first "big"(big for a beginner like me) project that I undertook with Tkinter and Pynput. Basically, this code will simulate an enemy's ...
4
votes
3answers
409 views
Loop to print changes in irrigation state to turn on and off a pump when water is low
Python Noob building an automation irrigation system in Python for Raspberry Pi.
Python has two functions in the most basic use case:
on/off the LED (which will in future be a relay->pump) and
...
2
votes
1answer
70 views
Yahoo finance option chain scraper
This is my 1st Python program I've actually written and I have little to no background in the language. I just figured I could learn and do something that interested me at the same time.
I'm not a ...
1
vote
2answers
69 views
Permuted multiples in python
How can I improve efficiency/readability of the following code?
It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.
Find the ...
0
votes
1answer
52 views
script to recover browser passwords
basically i am new to python lookin for any bad practices done down there in my script, any ways to shrink the code and increase efficiency
...
2
votes
1answer
115 views
Extract flight arrival data from web
I'm trying to scrape arrival data from Flight Radar 24
My script takes extremely long time to scrape the data. Is there any way I can speed up the scraping process?
Here's my script:
...
3
votes
1answer
58 views
Pygame program made to look like NohBoard
This is something I made as an input display resembling NohBoard because I need to make a video for a video game, but it's on Linux which doesn't have any good input display programs. One thing I'm ...
1
vote
0answers
14 views
Delete older EBS Volume snapshots except few with certain tags using Python, Lambda
I am learning Python and managed to accomplish the above. But my script doesn't seem optimal. Could someone help to take a review and suggest for betterment?
...
1
vote
2answers
134 views
Scraping webelements if found
Im currently working doing a webscrape which in my case if sydsvenskan but will be a template over time for other sites.
I have currently done:
...
0
votes
1answer
25 views
Config for each environment (for a simple Python SDK)
I have a simple SDK in Python for internal use.
It's basically 150~200 lines of code of simple API calls wrapped around nicely that is comfortable for us to use.
It holds a few clients with methods (...
3
votes
2answers
76 views
Round number to nearest non zero digit
I have the following code to round a number down to the nearest non zero digit in a string, or if the digit is larger than 1 it would round to the second decimal place.
I have yet to find a way to do ...
8
votes
2answers
566 views
Efficient renaming of dict keys from another dict's values - Python
I have a dictionary in Python (uglyDict) that has some really un-cool key names. I would like to rename them based on values from another dictionary (...
3
votes
1answer
38 views
Find number of ways to traverse matrix of 0's and 1's
I solved a Daily Coding Challenge, but i suspect my code could be optimised. The challenge is the following:
You are given an N by M matrix of 0s and 1s. Starting from the top left corner, how many ...
10
votes
2answers
668 views
Create a words histogram of a given string in python
I wrote a code that given a string (txt), will print a histogram that contains the number of occurrences of each word in it and the word itself.
A word is defined ...
1
vote
2answers
54 views
Checks if all nested objects don't have 'status' attribute as 'deleted'
I currently this code working, but its performance is very poor — 1.45 seconds seems a bit too much for a simple recursive if statement that only checks attribute values.
...
4
votes
1answer
363 views
Find next smallest number that's representable as a sum of distinct powers of 3
I'm solving this challenge:
Given a positive integer number, you have to find the smallest good number greater than or equal to the given number.
The positive integer is called good if it can be ...
1
vote
2answers
62 views
Account signup/login program in Python
This is my first program that I wrote on my own. Is there something I can improve upon?
There are a few things that still need to be added, such as:
Confirm password while registering
Adding a way to ...
3
votes
1answer
75 views
Python sensor calibration tool
all
This script's purpose is to check whatever the acceleration component s in order.
The IMU data sampled represent 2 samples of the imu measurements.
I'd love to hear your comments regarding ...
1
vote
1answer
44 views
Move all markdown files from one folder to another in Python
I want to move all markdown (.md) files from one folder to another. The folder structure I have:
...
2
votes
2answers
80 views
Finding pair of numbers that minimize a function
This is a problem of a past bioinformatic contest (requires an account). My solution works but is too slow for some test cases.
Input format
The first line of the input contains one integer \$T\$, \$(...
1
vote
3answers
141 views
Count prime numbers whose rotations are all prime
This code solves Project Euler problem 35:
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes ...
1
vote
2answers
83 views
Compute members of the infinite series generated by 2n+1 and 3n+1
Consider the infinite sequence u, where u is defined as follows:
The number u(0) = 1 is the ...
1
vote
1answer
33 views
Inserting Data to three linked table with SQLAlchemy
I am inserting data from a dict type object into three different tables in the SQL database. I am using Sqlalchemy as my ORM. My code is working but I think it is not very readable, is it any way to ...
8
votes
3answers
878 views
3
votes
0answers
58 views
Generate valid combinations of parentheses
Playing on leetcode coding problem: "Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses."
I realized that my understanding of Python was ...
3
votes
1answer
118 views
Killing a Hydra - Overengineered
Background
This question is inspired by the question: Killing a hydra, and my response therein. I will restate the problem at hand in full so that this question is fully self contained
You can only ...
2
votes
1answer
69 views
Python app thats simulate simple Stock Exchange
I wrote this simple app for creating a Stock Exchange platform.
It is written with a flask framework.
My main concerns are regarding the user_page route which feels too long and not DRY enough,
But on ...
1
vote
0answers
29 views
Python 3 script for statistiscal analysis of English vocabulary
This is a Python 3 script that statistically analyzes 105,230 words with a total of 913,935 characters, its results will be used for pseudoword generation purposes.
You will need this file for it to ...
1
vote
0answers
30 views
Applied Solution Based On Polya Enumeration Theorem
Problem
A function solution(w, h, s) that takes 3 integers and returns the number of unique, non-equivalent configurations that can be found on a grid w blocks wide, h blocks tall and s possible ...
0
votes
0answers
41 views
UPGMA tree building in python
As a part of coursework, I had to build an UPGMA tree from a given distance matrix and a list of species names. As a beginner/intermediate in python I saw this as a good opportunity to learn about ...