Questions tagged [python-3.x]

Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 3 interpreter only. Do not mix this tag with the python-2.x tag.

Filter by
Sorted by
Tagged with
1
vote
1answer
90 views

Calculate a time weighted average of a feature

I'm trying to calculate a time weighted average of a feature (feat) based on previous rows by date for a given ...
2
votes
2answers
100 views
4
votes
2answers
357 views

Web scraping data.cdc.gov for COVID-19 Data with Selenium in Python

I'm attempting to scrape data.cdc.gov for their COVID-19 information on cases and deaths. The problem that I'm having is that the code seems to be very inefficient. It takes an extremely long time for ...
2
votes
1answer
68 views

Cached shortened urls

Im currently writing my own cached shortened urls where I at the start of application read the database that has all the stored url:uuid from the database into a ...
0
votes
3answers
108 views

A Class that creates a unit of Stock or a collection of Stocks

I have a dataclass of a single class object 'AStock' as such: ...
2
votes
1answer
62 views

Identify files with 5 or more HTTPS URLs

I am working on a script that recursively searches a directory to find files which matches a regex 5 or more times. Using the script I can search for files which look like ...
1
vote
1answer
149 views

Day 3: Binary Diagnostic, part 1 (Advent of Code 2021)

Some notes that I thought would be worth mentioning up front: Advent of Code randomizes the input for each user, with the input format being 1,000 12-digit binary numbers delimited by newlines. I've ...
1
vote
1answer
81 views

Calculating all combinations from arrays AND (arrays OR floats)

Context: My question comes from needing to iterate different np.arange arrays. The main motivation is to calculate all the possible combinations between the arrays, ...
4
votes
1answer
408 views

Inefficient Solution - Advent of Code 2021, Day 3, Part 1

My code is working but it is extremely long. So, I guess there is a way to make it shorter/more efficient. The problem solved here is from Advent of Code 2021, Day 3, Part 1: https://adventofcode.com/...
4
votes
1answer
57 views

API call scheduler for Python

My favourite 3rd party library isn't getting maintained so now I need to make my own library for interfacing with Riot Games' API. Epic. Problem is that there are rules, such as: 100 requests in 2 ...
2
votes
1answer
43 views

Read file from current path in Python

I had to write a custom function to load a yaml file from the current working directory. The function itself works and my intention was to write it in a pure fashion but my senior colleague told me ...
4
votes
3answers
705 views

Produce a list of every 1st, 3rd, and 5th Friday of each month in a date range

When fridays_135 is called, a list of dates between the start date and end date is produces by date_range. That list is then narrowed down to just the Friday dates and then grouped by month by ...
0
votes
1answer
74 views

Simple sort function

I am learning Python and for practice I have written this function which sorts a list. Can you please provide feedback on how I have structured it and what better ways could be there to write it for ...
3
votes
2answers
660 views

Magic ball 8 program

I was doing the Magic Ball 8 project (its task is to read a user's question and output a prediction) on Python and wrote the following code: ...
3
votes
3answers
92 views

Finding the next 9am/pm from now

I have some code that needs to return a datetime of the next 9am or 9pm, UTC. I've figured out some code to do this, but it feels unnecessarily complex to me. Is ...
4
votes
2answers
248 views

Remove matching lines from all files

I have written a Python3 program that looks for matching strings and removes them from files. ...
4
votes
0answers
101 views

Student report card management Python program

The program is designed to take data from a MySQL database, using mysql-connector-python, and print it as a table in Python using the texttable module. The program also plots charts based on the data ...
-2
votes
1answer
135 views
1
vote
1answer
86 views

Python IPv6 verifier, parser and converter

This is a simple Python 3 program that verifies whether a string is a valid IPv6 address or not, parses IPv6 address to its hexadecimal and decimal values, and converts an integer to IPv6 format. I am ...
2
votes
0answers
42 views

Naive Bayes spam classifier improvements

Could you please have a look at our naive bayes model. We look at a corpus of emails where an email is either spam or not. To classifiy we naively assume a bag of words and estimate prior ...
2
votes
1answer
85 views

Stop exam cheating using python: Part 2 - Argparse and config

Intro This is a spiritual successor to the question Stop cheating on home exams using python The details are not important, but I decided to reimplement everything using dataclasses. My script is now ...
1
vote
1answer
46 views

Printing reverse number triangle

I have to write a program in python that will take a number and print a right triangle attempting to use all numbers from 1 to that number. For example: ...
1
vote
1answer
82 views

Evaluating infix expression with brackets

My assignment was to write a function that computes the value of an expression written in infix notation. We assume that we are using the four classical arithmetic operations +, -, * and / and that ...
0
votes
0answers
31 views

view only INFO in console and save CRITICAL, ERROR, WARNING to log file

The following code log INFO in terminal and WARNING, ERROR or CRITICAL in file. my python file looks like: ...
4
votes
1answer
113 views

Return the biggest loss a client made from prices list

A hiring company gave me the following challenge: We want a function which accepts a very large list of prices (pricesLst) and returns the largest possible loss a ...
1
vote
1answer
39 views

When I try to re set up my code after failing in the game I cant get it to run the function without its own file being undefined [closed]

I know my code is ugly and unreadable. I originally had the game working without class functions but when I had to implement class function it all went downhill. TennisMaster.py ...
0
votes
0answers
41 views

Python 3 Table Improvements

(reposted from another forum, AoPS) I have made a "Table" data structure with fast mean, median, and mode calculations. To my knowledge there's no built-in function that does this. Here's my ...
0
votes
1answer
91 views

How to speed up the search for matching values in a second data frame in a line-by-line iteration over a first data frame?

I have a survey response dataframe for which each survey has a code: df ...
2
votes
1answer
88 views

Evaluating postfix expression on multidigit numbers

This is my solution for evaluating postfix expression using a stack. It does work on multidigit numbers, the problem I was struggling with last time. Now it works completely fine. This is the stack ...
3
votes
0answers
21 views

Make selected colours brighter in Blender

The problem: I am working with a set of objects in Blender with per-vertex colours. Each object has only two distinct colours. For all objects in a selection, I am choosing only the brighter of those ...
15
votes
5answers
1k views

Check whether a lowercase string has any character repetition

I got this HW question from my freshman year at college - "Create a python function to check whether a string containing only lowercase letters has any repetition in it". So, I did it a few ...
0
votes
0answers
12 views

Optimizing data processing of netCDF file

I am extracting/processing some data from a netCDF file. It is the first time I am processing the netCDF file. The data processing is super slow, and I would like to learn how to speed up the process. ...
2
votes
0answers
72 views

Web scraping articles using asyncio

I use asyncio to speed up web scraping. I collect only title, author, tags, datetime, total comments from list view from specific website. Also, i collect these from all pages. I would like to improve ...
2
votes
0answers
96 views

Python 3 simple PyQt6 GUI program that helps text processing

I am not sure how to accurately describe what this program does in just a few words, anyway this program is very simple and easy to use, what it does is very simple and it is good at it. Let me start ...
2
votes
0answers
84 views

Python Markov Chain based pseudoword generator

This is a Python 3 module that generates random pronounceable word-like strings based on Markov Chains. It has many modes, each mode conforms to the structures of dictionary words to a degree, the two ...
0
votes
0answers
49 views

Python Class for config file parameters

I have created the below script in which I'm trying to set up a class for handling a config file, but also defining some functions that I call from the class methods. Not sure if I'm following the ...
3
votes
3answers
413 views

Find the average score, given data in a table with labeled columns not in a fixed order

I was on Hacker Rank for the first time and there was a question that required to get the inputs from STDIN and use collections.namedtuple(). It was my first time ...
4
votes
1answer
68 views

Function to calculate the GC content variation in a sequence

I came across this BMC Genomics paper: Analysis of intra-genomic GC content homogeneity within prokaryotes And I implemented some Python functions to make this available as part of a personal project. ...
0
votes
0answers
53 views

Class to save the parameters of every function call

I wrote a function saving class which basically saves data of every function that's being called ...
6
votes
2answers
197 views

Container with most water, with pre-computation of possible bounds

Here's my attempt at leetcode's container with most water. Problem: Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn ...
3
votes
1answer
116 views

Web scraping international trade data

I'm trying to scrape arrival data from this website. 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: ...
1
vote
2answers
83 views

Generate a string that is not present in a list

For a college assignment, I was tasked with the following (excerpt from provided code file): Find one string of characters that is not present in the list. You are provided a function that loads the ...
0
votes
1answer
84 views

Python 3 weighted random choice function memoized version

I have written a function that randomly picks one element from a set with different probabilities for each element, anyway it takes a dictionary as argument, the keys of the dictionary are the choices ...
1
vote
2answers
57 views

easy to use control panel for minecraft rcon

I wrote a small program that connects to a minecraft rcon and provides an easy to use control panel. It is written in python 3.9 and uses the kivy module for the GUI. What could I improve in the code? ...
6
votes
1answer
117 views

Decorating __init__ for automatic attribute assignment: Safe and good practice?

I am currently trying to better my understanding of python and good coding practices and would really like some input on a question i have been thinking over for weeks now. I am currently working on ...
4
votes
2answers
193 views

i3 config file parser

So I am using i3 an Linux window manager to manage my windows. In addition this is run on a laptop that is frequently mounted to several output-displays. This is handled by the following lines in my ...
4
votes
0answers
88 views

Sudoku sequence solver for non-standard constraints

This script is designed to help solve sequences in Sudoku puzzles with variant constraints (ex: Thermometer, Renban, etc.). Summary The user specifies the constraints they want applied as well as the ...
2
votes
1answer
107 views

How to make my Collatz Conjecture code run a lot faster? (and even better, how do I implement it into multiple computers?) Python

I have been writing this piece of code for a while now, and I was wondering, is it possible to run this code multiple times on my pc? For example could I make the code solve all the numbers from 1 to ...
1
vote
0answers
84 views

Python functions to serialize nested data structures human readably

See Serializing (nested) data structures in a human-readable format for more details. In the last two days I have significantly improved my function, and wrote seven implementations of it. I have ...
1
vote
2answers
90 views

TextRPG written in python

I started to write a terminal based text RPG in python. Its mostly bug free now but I really want to know how I could improve my code and how to implement things better. I know it's a lot of code so I ...

1
2
3 4 5
99