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
3 votes
1 answer
69 views

Scraping website with Python and Selenium to collect data from dynamic website

Summary: The code scrapes the website and collects the data to store it in CSV. It also downloads selected information that is available for download in PDF format. The details and the entire code are ...
sangharsh's user avatar
  • 279
12 votes
2 answers
1k views

Space shooter game using pygame

I have made a space shooter game in pygame with over 800 lines of code (including blank lines). The aim of the game is to kill all of the ships in the game. You start with a small spaceship and one ...
coder's user avatar
  • 121
1 vote
0 answers
55 views

Django Google Authentication App Using OAuthlib and DRF

Context I've been working on a Django-based Google Authentication application, designed to manage OAuth authentication without relying on libraries such as ...
Grajdeanu Alex's user avatar
3 votes
1 answer
81 views

Multiline string concatenation

Problem Description Printing the result of adding two numpy arrays together is very ugly. Here we will use these numpy arrays as an example: ...
mikeLundquist's user avatar
4 votes
1 answer
64 views

Centre of mass based TSP solution (2)

I updated the code to a working state. My previous question. Even if this code working I wonder if I can write this code in a more efficient way. Maybe less for loops Etc. ...
tumr's user avatar
  • 51
2 votes
2 answers
83 views

Checking file header for magic number in Python

I wrote this to check files for successful compression with LZ4. Any advice is welcome. Particularly regarding raising exceptions and error handling. ...
voices's user avatar
  • 767
3 votes
3 answers
171 views

Converting a dict to a list + ID

I wrote this code: PROJECTS_LIST = [ project if not project.update({"project_id": project_id}) else None for project_id, project in PROJECTS.items() ] ...
UCYT5040's user avatar
  • 151
0 votes
1 answer
104 views

Centre of mass based TSP solution

This is the code that I tried to approach to the traveling salesman problem in a new way. As you can see, it does not give such great results. Can I get this idea further, or should I quit to ...
tumr's user avatar
  • 51
2 votes
1 answer
44 views

A selenium web scraper to package NBA data

I'm building a selenium web scraper for basketball-reference.com that takes a player name and returns data in either a JSON format or Pandas DataFrame object. The class in question is one of many that ...
BluffShove's user avatar
2 votes
4 answers
658 views

Adding Node to Linked List

I've been programming for 3 months now, and I've just come across Linked List, and I'm not gonna lie, I've been struggling a little. I wrote this code to practice on Linked Lists. The purpose is to ...
fraber's user avatar
  • 179
4 votes
4 answers
1k views

Creating an O(n) algorithm for an array of integers

To avoid plagiarism in my university, I am going to modify the problem. Henry likes to jump from building to building. The heights of each building are given as a list of H numbers. We also number ...
Duckycodes's user avatar
4 votes
2 answers
286 views

Simple version of NEAT

I have wrote my own simple version of NEAT and want to improve the code for mainly performance (training and runtime of a generation). This simple version of NEAT aims to perform somewhere near as ...
coder's user avatar
  • 121
3 votes
1 answer
121 views

Miller-Rabin implementation is very slow

I implemented the Miller-Rabin-Primetest in python3. But I have the feeling it is very slow. I know that there are faster version in gmpy2 package, but I want to compare it with another code I have in ...
Lereu's user avatar
  • 141
3 votes
1 answer
86 views

Sorting songs with the ability to save and resume partial sorts

I listen to a lot of music (~4k h/y) and managing thousands of songs is a bit of a challenging. To improve my listening experience I want to better organize my collection. One thing I want to do is ...
Peilonrayz's user avatar
  • 43.3k
1 vote
2 answers
109 views

Miller-Rabin prime test

I have an implementation of the Miller-Rabin prime test, coded in Python 3. I want to use that as a comparison to a prime test which I coded myself. Unfortunately I have no idea how "fast" ...
Lereu's user avatar
  • 141
3 votes
2 answers
133 views

Copy and delete Pathlib.Path

I want to copy or delete a Path object, whether it is a file, a symlink, or a directory. I don't want to monkey patch Pathlib so I created some surrogate functions for those operations: ...
FTG's user avatar
  • 165
1 vote
1 answer
62 views

Dynamically mapping an API's setting IDs to instance methods using Descriptors

I'm working with an API, where the url can be constructed with setting_ids. To more clearly indicate the functionality of the setting ids I am mapping them to a WriterClass' methods, with relevant ...
Floriancitt's user avatar
1 vote
1 answer
46 views

PySpark: Create a column containing the minimum divided by maximum of each row

I am working out some PySpark exercises and trying to write efficient and best practice code to be ready to work in a production environment. I could use some feedback with respect to: Is the code ...
Jongert's user avatar
  • 29
7 votes
2 answers
429 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 ...
Андрей Александров's user avatar
3 votes
2 answers
129 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. ...
friday-json's user avatar
2 votes
2 answers
133 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 ...
spaghetticode's user avatar
0 votes
1 answer
73 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 ...
Jan_B's user avatar
  • 109
4 votes
6 answers
716 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. ...
Jonah Mitre's user avatar
1 vote
1 answer
62 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 ...
rdesparbes's user avatar
0 votes
1 answer
99 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 ...
KhodeNima's user avatar
  • 349
1 vote
3 answers
138 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. ...
chateaukey's user avatar
4 votes
1 answer
90 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,...
spaghetticode's user avatar
6 votes
2 answers
683 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 ...
Cam's user avatar
  • 235
1 vote
1 answer
127 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 ...
Murilo Perrone's user avatar
6 votes
2 answers
699 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 ...
Aldis Nuts's user avatar
5 votes
2 answers
512 views

Partial pivoting code in python

...
JustAnotherMind's user avatar
3 votes
3 answers
328 views

Matcher/Searcher with Glob support

Let's say I have data like this: ...
ClaireM's user avatar
  • 31
3 votes
0 answers
77 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, ...
EdG's user avatar
  • 31
1 vote
1 answer
38 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 ...
KhodeNima's user avatar
  • 349
3 votes
2 answers
131 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 ...
Green绿色's user avatar
2 votes
1 answer
116 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 ...
sean's user avatar
  • 61
1 vote
2 answers
125 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 ...
Floriancitt's user avatar
6 votes
2 answers
725 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 ...
baijugoradia's user avatar
4 votes
1 answer
155 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 ...
sbottingota's user avatar
3 votes
1 answer
148 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 ...
sean's user avatar
  • 61
0 votes
1 answer
142 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 ...
sean's user avatar
  • 61
2 votes
1 answer
104 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, ...
Linny's user avatar
  • 10.1k
2 votes
1 answer
55 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 ...
Just Bucket's user avatar
5 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 ...
Ranch Mayonaise's user avatar
2 votes
1 answer
117 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 ...
Afasys's user avatar
  • 21
5 votes
1 answer
212 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 ...
Karn Kumar's user avatar
2 votes
2 answers
94 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 ...
Jossy's user avatar
  • 153
5 votes
2 answers
181 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 ...
fraber's user avatar
  • 179
3 votes
1 answer
91 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 ...
sbottingota's user avatar
3 votes
2 answers
446 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 ...
Michael's user avatar
  • 303

1
2 3 4 5
108