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
4 votes
6 answers
630 views

Look and Say sequence function

This is my first rough attempt at creating a function to return the nth number within the look-and-say sequence. I'm pretty sure there are some ways to simplify it, even given my current approach. ...
3 votes
2 answers
2k views

Date Detection with Python RegEx

its a practice project from "Automate the Boring stuff with Python" book. i am an intermediate level Python programmer and i tried to solve this problem with less code as possible. This code ...
7 votes
2 answers
410 views

Mathematical calculation of engine fuel injectors

There is a code that performs calculations of parts of fuel injectors. There are two classes in which the basic calculations take place, they are called ...
3 votes
2 answers
96 views

Simple Python text file Parser and Converter

I wrote a simple text parser and a converter using Python 3.12.1. The purpose is to read a text file that contains 20000 words one per line, and create an output file that contains all the queries. ...
0 votes
1 answer
69 views

Reassure user that python code is running during long imports

I have created a large module for downloading data from SAP and editing and displaying it on a plotly dashboard. While the code is running as desired there is one problem that bugs me: The submodules ...
2 votes
2 answers
121 views

SQLite querybuilder class in python

Motivated by the first commentor's suggestion on my MSAccess question: Python SQL insert to MSAccess with VBScript I am moving to use SQLite databases for a python application and I created this query ...
-2 votes
0 answers
27 views

Unnest dictionary of arrays from JSON [closed]

I am trying to port code from R to python. There are different types of JSON inputs which needs to be transformed. Inputs: Sample#1: ...
2 votes
0 answers
301 views

A thread-safe WebDriver pool to submit browsing jobs to

For a project, I need to make use of Selenium WebDrivers, and since they're so expensive to start, I decided to write a pool to manage them. ...
-1 votes
0 answers
46 views

Ordering soldiers so they don't stand next to others they dislike

I wrote a solution to a competitive programming question, however my solution seems rather long and slow compared to others. Tips are much appreciated. Solution to the question Carnival_General. The ...
1 vote
1 answer
48 views

Event manager based on decorators

This module is a simple event manager that works with decorators. I would like feedback on: Bugs Any ideas to get rid of the classevent decorator, which ...
0 votes
1 answer
70 views

Python exception for handling invalid argument types

Greetings One small problem that anyone have to tackle with in Python is handling invalid argument types ( without an automatic static type checking tool like Mypy ) One of the best methods for ...
1 vote
3 answers
104 views

Random number guessing game (1-100)

I'm making a random number guessing game in Python. Any suggestions? I'm going to add a restart button to it. ...
5 votes
2 answers
2k views

Python code to calculate STM CRC32

I have code to calculate STM CRC32 in python. It works well but I'm shocked from time when I see how much it takes. Namely calculating for 5120 bytes takes about 20ms (or even more)! Now I'm thinking ...
6 votes
2 answers
662 views

Speed up search function for PDFs

This function takes a file path to a PDF file, and a search string(s). It spits out a count of the number of times the string(s) shows in the PDF. Any ideas how I can make it faster? It can be tested ...
4 votes
1 answer
82 views

Python SQL insert to MSAccess with VBScript

I have a business use case that required running SQL insert queries to a local MSAccess database with a Python script. The actual script does many other things and the SQL function is just one of them,...
1 vote
1 answer
117 views

Read millions of integers from stdin and process them in Python within 2 seconds

This is a competitive programming problem which has never been solved in Python within the time limit of 2 seconds. It is about Disjoint Set Union: Source: Algorithms In Context #10: Disjoint Sets ...
1 vote
1 answer
459 views

An implementation of Uber's "Fare Estimator" [CodeSignal]

CodeSignal put out a challenge by Uber that involves writing a "fare estimator" that involves a function dependent on cost per minute, cost per mile, ride time and ride distance. The formula ...
7 votes
3 answers
4k views

Finding the position in a triangle for the given challenge

The LAMBCHOP doomsday device takes up much of the interior of Commander Lambda's space station, and as a result the prison blocks have an unusual layout. They are stacked in a triangular shape, and ...
6 votes
2 answers
674 views

Making a Rock Paper Scissors game in Python - How to reduce repetition and make it more effective?

I am a "new" coder to Python - saying this because I got stuck in the tutorial hell - and I saw that doing projects was a way of consolidating what I had learnt from those tutorials, so here ...
2 votes
1 answer
115 views

Birthday database and emailer

This is my third project for review; I would like feedback on: code readability code efficiency particularly good parts The project is called BirthdayBackup. It's a GUI app that allows you manage a ...
5 votes
2 answers
502 views

Partial pivoting code in python

...
3 votes
3 answers
309 views

Matcher/Searcher with Glob support

Let's say I have data like this: ...
3 votes
2 answers
113 views

A simple search-and-replace algorithm

In recent times, I've been using the following algorithm repeatedly in different languages (Java, Python, ...) to search and replace strings. I don't like this implementation very much, it's very ...
3 votes
0 answers
74 views

Rock Paper Scissors, with changing weapon sets and player preferences

The task The goal here is to build a RPS engine that can run tournaments of RPS games between different players. The initial version has been written with the Rock Paper Scissors Spock Lizard ruleset, ...
1 vote
1 answer
35 views

Python3 Unix command_line_interface task organizer application using argparse

Greetings. Lately I've tried to use a branch of text_formatting rules to enhance my productivity while working with different integration tools such as Git, but this formatting convention went so ...
2 votes
1 answer
54 views

Average Pair Sorting algorithm

I had to relax a bit, so I wrote this sorting algorithm. By any means it isn't fast, but I really started to get interested in it, since I haven't seen similar approach yet. Disclaimer I do not intend ...
0 votes
2 answers
91 views

Mapping an API's setting IDs to setting names with class methods, enabling clearer utilization

I'm trying to access an API using the requests library in as clean a manner as possible. The API is accessing various settings of various devices. I'd like to keep my code as readable and ...
3 votes
1 answer
142 views

Python - beginner - GUI

I have been learning python for 1.5 month now I am learning in my free time between job and other life commitments so my progress may be slow. It may take time for me to reply but I am interested in ...
4 votes
1 answer
148 views

Roman numerals look and say sequence

I was practicing question 1 of the 2020 british informatics olympiad past paper: The Roman look-and-say description of a string (of Is, Vs, Xs, Ls, Cs, Ds and Ms) is made by taking each block of ...
5 votes
2 answers
715 views

Convert an array of strings into datetimes with different formats

I am trying to write a python function to convert an array of strings into an array of datetime objects where string can be in one of two formats, and would like to ...
0 votes
2 answers
148 views

Program for monitoring file in Combined Log Format

After encountering a suggestion that monitoring a log file for a webserver could allow for the implementation of automatically analyzing and handling of certain events (that might require altering ...
2 votes
1 answer
97 views

TUI Slot Simulator

Wrote a slot machine for a larger casino TUI project I'm creating. Would like some general feedback, along with some specific things: Coloring: Currently I have three loops that are almost identical, ...
0 votes
1 answer
105 views

Python - beginner level - password manager GUI

I have been learning Python for 1.5 months now. I am learning in my free time between jobs and other life commitments so my progress may be slow or it may take time for me to reply but I am interested ...
4 votes
3 answers
2k views

Leetcode problem 8 (atoi). Why is my solution so slow?

This is my solution to Leetcode problem 8, the atoi problem, in Python 3. This is just a generic atoi routine that converts any ...
6 votes
3 answers
703 views

LIFE in Python 3

I have started to learn Python and have chosen Conway's game of life as my first program. I would be interested in reading how to write more idiomatic Python. Also, what threw me off for some time was ...
2 votes
1 answer
72 views

Codewars 4 Kyu kata: "Most frequently used words in a text"

This was the first kata I found hard so I wanted to ask about it. Any ways I could I have done it better? here's the question -> Most frequently used words in a text ...
3 votes
1 answer
126 views

Django User Model to authenticate using email address and password

This is my second Django project for an actual client and I want some review on one of my important models. This model will be responsible for authenticating users using their E-Mail Addresses and ...
0 votes
2 answers
99 views

Feedback On How I Can Clean Up My Code

I am new to coding for ~1 week. I know that I learn best by doing, and so I decided to work on a small and simple project while utilizing various online sources to learn as I go. Anyway, I decided to ...
5 votes
1 answer
210 views

Compute the mean of a series of user-entered numbers

Which is more elegant out of two methods as mentioned below mostly from memory prospective? Both methods achieve the same result, but from a memory perspective, In Method1, we are storing the running ...
1 vote
1 answer
52 views

Re-write of PDF invoices from user input, decoupling of Invoice from FPDF class

Following on from this post and taking on board some of the suggestions, what follows is a re-write of the original python code. It's also just a rewrite of some of the functionality, this code only ...
3 votes
1 answer
90 views

Finding the number of "block chains" that are a certain length and begin with a certain string

I'm currently practicing for the british informatics olympiad by doing past papers. I was doing question 3 of the 2019 paper: A set of children’s blocks, each illustrated with a single different ...
1 vote
1 answer
498 views

Finding longest word in a sentence

A problem from Coderbyte. Find the longest word in a sentence after removing the punctuations and if two or more words are of same length return the first word Below is my solution: ...
5 votes
1 answer
127 views

Approximation search source reconstruction localization algorithm

Goal To determine the coordinates of some signal source in a 3D space, given the coordinates of four observers and the time at which each saw the signal, as well as the velocity of the signal. ...
2 votes
2 answers
89 views

Starting with a list of initials and last names, extract full names from string of names [closed]

Starting with the following list of initials and last names: ['Arnold-Ker L.', 'Dutra Da Silva R.', 'Bracciali D.', 'Dlouhy L.'] I need to extract the full names ...
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 ...
5 votes
2 answers
168 views

Function to search all words matching a search term

I'm solving a python exercise. Here is a brief description: Please write a function named find_words(search_term: str). It should return a list containing all the words in the file which match the ...
1 vote
1 answer
68 views

Python3 tokenizer abstract baseclass ( Without the permission to be instantiated directly )

I'm a newbie python developer, and fortunately I have been introduced to the principle of abstract base classes and they seemed pretty interesting to tackle while going forward in my Python journey. I'...
2 votes
1 answer
105 views

Pong using pygame module

I made a game in Python where you play Pong against an AI. As I am quite new to pygame, I would be grateful to hear any possible improvements. This is my code: ...
3 votes
1 answer
114 views

Merging pages together into an append log

Situation I'm scraping data from a paginated list on a website to be sent out as notifications. For the most part we'll only need to scape the first page and handle additions, deletions and duplicates....
3 votes
2 answers
438 views

Hardware API, primarily for Error handling

I have a piece of equipment that I am interacting with. The manufacturer provided an SDK and some simple examples of how to interact with the device. However, I need to write an API for interacting ...

1
2 3 4 5
107