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
2
votes
1answer
20 views

Python PyQt6 populate QTreeWidget with a list of named tuples

This is a Python 3.9 script that pulls data from a MySQL database and converts it to a list of named tuples and then passing it to PyQt6.QTreeWidget. It has to be a ...
1
vote
1answer
35 views

Python script that makes ngrams

This is a Python script that generates ngrams using a set of rules of what letters can follow a letter stored in a dictionary. The output is then preliminarily processed using another script, then it ...
3
votes
2answers
41 views

Better solution to pass arguments to function in a dictionary

I've just started learning python, mostly by some YouTube videos and other online tutorials. Now I want to create a dictionary of callables (actions) asking for user input (a hotkey), but the user ...
-1
votes
0answers
15 views

Receiving messages in TCP chat room, Python3 [closed]

I'm working on a TCP chat room using socket module, and I looking for a reliable way for receiving data (text only), ensuring whole message delivery, like WhatsApp (the messages are always received). ...
9
votes
3answers
380 views

Asynchronously scrape fabric information

This is my first asyncio/aiohttp web scraper. I am trying to wrap my head around Python's asyncio/aiohttp libs these days and I am not sure if I fully understand it or not yet. So I'd like have some ...
-1
votes
0answers
21 views

How to change logging configuration from within my own code, without touching the code in the (upstream) module? [closed]

This code demonstrates how to log stuff from inside my class. It is a simplified version of what I find in a module called mptools. Now I want to use this kind of logging in my project, together with ...
1
vote
1answer
93 views

Shopping list using Python 3

In this python program, I used lists and control flow to allow users to add items to a shopping list and display the list. I need advice on my code in terms of (architecture, risks, opportunities, ...
3
votes
2answers
71 views

Ticketing program using Python 3

In this python program, I built a ticketing system with functionality such as keeping track of tickets sold and error handling in case there are any invalid inputs. I need advice on my code in terms ...
6
votes
1answer
519 views

Analyzing average movie budgets using Python 3

This python program analyzes movie data by finding the average budget of films in a data set - it also identifies films that exceed the average budget calculated. I need advice on my code in terms of (...
0
votes
0answers
17 views

Python script to replace GitHub password with tokens

I manage a fleet of IoT devices. As for now, GitHub announced that the username-password authentication would be deprecative soon, so I have to change the password on each device to the GitHub access ...
-1
votes
1answer
49 views

Proper way to Implement a Birthday Class in Object Oriented Python [closed]

I have the following class ...
7
votes
2answers
389 views

Named tuple with less-than operator

I have the following implementation for the __lt__. Could you please check if it's okay to compare objects like that? ...
3
votes
1answer
57 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
2answers
119 views

Temperature Converter: °C to K

What it does Converts melting point and boiling point from degrees celsius to kelvin These are in a dict which is in a tuple as no changes should be made to it No user input Purpose Learning ...
0
votes
0answers
18 views

Logistic regression using Sklearn in Python

I'm trying to learn how to use logistic regression with Sklearn. After learning the theory, I tried implementing it using the Heart Attack Analysis datasheet from Kaggle. Here's a snippet of the data: ...
3
votes
1answer
47 views

Simple Python Recursive Web Scraper

I tried to make a simple recursive web scraper using Python. My idea was to grab all the links, titles and tag names. Website: https://lifebridgecapital.com/podcast/ Course of Action: Grab all the ...
3
votes
1answer
49 views

Particle swarm algorithm with multiple threads

I wrote a simple multitthreading program which does particle swarm optimization. Optimization itself and some corresponding functions were taken from https://nathanrooy.github.io/posts/2016-08-17/...
7
votes
1answer
297 views

Genetic algorithm to guess coefficient of a polynomial

I have tried to code a genetic algorithm to guess the coefficients of a degree 4 polynomial. The information initially provided is values of y = f(x) for different x using the original polynomial. I ...
8
votes
2answers
90 views

Representing Tic-Tac-Toe using a binary BitBoard

So I have been learning more about binary numbers lately, particularly in related to describing a gamestate. While perhaps chess is the most natural candidate I wanted to start of with something ...
3
votes
0answers
44 views

Speed Up API Requests & Overall Python Code

I'm not asking for help solving a problem but rather asking for help for possible ways to improve the speed of my program. Essentially what this does is: Tracks market data by pulling the data from ...
1
vote
1answer
39 views

Tic Tac Toe (new draft)

I have implemented suggestion and created new draft of the Tic Tac Toe program. Please review and let me know where I can improve. ...
5
votes
2answers
51 views

Count *.plot files in certain directories on network filesystems

First of all, I am playing around with python for about a week tops. Absolute beginner here. My story: I work as an IT administrator so I am familiar with eg. PS on a very basic level. I actually got ...
1
vote
1answer
70 views

Tic Tac Toe program

I have created a simple Tic-Tac-Toe program. Can someone please review it and let me know where I can improve. Here we can play against computer. Program start by putting 'X' at the center that is at ...
1
vote
1answer
41 views

Discord.py pages for a leaderboard

So I've got a Discord bot that will load information about a user's personal charts and display it to them, and one of the commands is to get their leaderboard and show them the most successful songs ...
4
votes
2answers
247 views

Mean difference calculator for any int combination

What it does Calculates the mean difference for a list of any combination of ints (I think). What I want to know The only other way I can think of doing this is using recursion. I’d like to know if ...
3
votes
1answer
56 views

TCP chat room in Python3

(Previous question) I've created a server file, that keeps waiting for clients. When someone connects to the server, he can send messages to the server, and from the server it is broadcasted to all ...
7
votes
2answers
90 views

Python script for alerting disk usage and take action if needed

I am running an IoT fleet, and the need for checking the empty disk usage space has increased. So I am using the following python code. In addition to best practices, efficiency, readability, pythonic,...
7
votes
1answer
167 views

Stop cheating on home exams using python

Background I am teaching a course at university level, and have lately been working on creating a home exam for my students. However, the institute has given clear instructions that collaboration is ...
0
votes
0answers
17 views

User input, floats, ints and ranges

Intro So I am writing a larger script where a part of it is checking user input. Maybe I have a menu where the user can choose different options, or maybe I want them to write in some number/s. After ...
3
votes
2answers
61 views

Python 3 approximate pi using 9 algorithms

Note: this script requires gmpy2, if you are using Python 3.9.5 x64 on Windows 10 21H1 like me, then you need to download the pre-built ...
2
votes
1answer
21 views

API design of library for argument inspection & filtering

I wrote the following Python library for getting a callable's argument names, testing whether a callable takes an argument with a given name, and filtering a dict ...
4
votes
1answer
203 views

TCP chat room in Python 3

I've created a server file, that keeps waiting for clients. When someone connects to the server, he can send messages to the server, and from the server it is broadcasted to all clients. Can you ...
-3
votes
1answer
47 views

Generating a Latin Square (Modified Algorithm) [closed]

Sifting is used to create a Latin Square of distinct symbols. The sifting is implemented by swaps on an array. The symbols might be strings or integer, but they are required to be distinct. Notably, ...
2
votes
1answer
72 views

Generating a Latin Square

I created an algorithm for generating Latin Square. The algorithm uses the first n permutations (Not n!) orderings of a distinct row of numbers. This is then assigned to a 2d list. ...
2
votes
1answer
37 views

Optimizing telegram bot

I was working on one telgram bot, and when finally i made everything i discovered that it is extremely slow. def s takes 5-7 seconds to get result and send it to user, i tried to optimise it with ...
1
vote
2answers
411 views

Search Method In Python / Python 3.9

I have implemented Binary_Search in python (I think), and my own method for range objects. I want to know if there is any way to improve this code, here it is: <...
5
votes
1answer
46 views

An IEEE half-float implementation in python similar to array.array, is there any way I could make this more efficient?

I've written this class to wrap a collection of bytes and interpret them as 16-bit floats. It's supposed to work like memoryview(buf).cast('f') or ...
0
votes
1answer
39 views

Short function to check if an entered answer is close to a correct one

I had this trivia game, and from the review I got I improved my game. One of the improvements I made was this short function, to check the correctness of an answer (so if the correct answer was "...
3
votes
1answer
59 views

Mapping CSV columns

I have the following code where I am trying to map columns from the input file to output. I have written it using multiple loops. Is there a way to write this more efficiently? input.csv: ...
3
votes
1answer
89 views

Python Place +,-, nothing between 1, 2, …, 9 (in this order) whose sum is 100

So this is a programming challenge I saw: Write a program that outputs all possibilities to put + or - or nothing between the numbers 1,2,…,9 (in this order) such that the result is 100. For example ...
2
votes
0answers
53 views

Start and kill thread on given pid

I have been working on I/O Bound application where I want to learn how I can kill a thread on given PID, by PID I mean a specific URL I want to kill as I later on will do an API or listen to a stream ...
2
votes
1answer
73 views

Dose tracker with daily and weekly totals

This is an old script I made a while ago. What it does It tracks your dose of whatever you want tracked (cigarettes, salt, etc), outputs the total for each day, and the full week. What I’m looking for ...
3
votes
1answer
49 views

Ask for user input and again on the same line

A function that asks for user input according to some criteria and again on the same line if the criteria is not met. It requires that escape character sequences be enable. ...
3
votes
2answers
62 views

CLI ASCII Maze Generator / Python 3.9

I made a maze generator in python that outputs in CLI. With mazes that are extremely big, it can take a while to output. I want to know if there is any way to increase the efficiency of this code. ...
5
votes
1answer
335 views

A Prime-Generating Algorithm and Python Script

I was wondering if it would be possible to optimise my python script? It is designed to quickly generate and print all the prime numbers under some inputted number. It is fairly fast currently, and I ...
2
votes
1answer
57 views

Brute Force Password Program / Python 3.9

I've been making a brute force program for fun. This program tries to guess a password using brute force. I've tried many things to help increase the efficiency. Here it is: (Sorry for the lack of ...
2
votes
1answer
48 views

PyQt5 GUI for setting user configurations and calling main procedure

This module is the main GUI for a project I'm working on. It's not yet final, but I feel I've become somewhat blind to potential improvements / refactorings, but I'm sure there are plenty. The module ...
0
votes
0answers
26 views

How to most efficiently make repeated calls to API with Pandas/Python

Looking for some help on how to speed up the code below as I'm still relatively new to using Pandas. The playoff_stats function makes thousands of calls to the PlayerCareerStats API - and while it ...
4
votes
3answers
222 views

Python random word generator that generates a wordlike pronounceable string

This is a random word generator I wrote in Python 3 today, I don't know how many Python implemetations of this exist, but this is my first try and it is completely working. It returns a random word ...
4
votes
1answer
75 views

class that handles the rpg game map

I created a class to handle maps in my RPG game, before it became a class this was a collection of functions I created, but I thought it could be used as a class. although this code is working but i ...

1
2 3 4 5
94