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
votes
0answers
5 views

Python text based adventure game Getting items

So essentially I need to be able to get the items from rooms and my code keeps giving me a key error. I also need help in when you reach the boss you fight the boss and if you have all of the items ...
1
vote
1answer
68 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 ...
4
votes
2answers
131 views

The optimized way to find the top k leading candidates from a unsorted hash map in python

I need to write a method that will accept a timestamp and takes an array of votes, I need to return the k leading candidates with that timestamp. I came up with the ...
5
votes
1answer
746 views

Coffee machine project using Python OOP

This is my first project using Python OOP. I don't know whether the code I have written is correctly or not. How can I make this code feasible? Machine.py Class containing some default values ...
2
votes
1answer
50 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 ...
2
votes
0answers
37 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
2answers
60 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: ...
0
votes
1answer
58 views

Python - 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
288 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/...
-2
votes
0answers
27 views

Is The Logic Of This Program Correct? [closed]

I need to write a program that calculates ingredients for a recipe. Here is the question: A cookie recipe calls for the following ingredients. 1. 1.5 cup of sugar 2. 1 cup of butter 3. 2.75 cup of ...
4
votes
1answer
47 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 ...
4
votes
3answers
677 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 ...
2
votes
1answer
32 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 ...
1
vote
1answer
5k views

Created a frame with a disabled button, till check button is used, then return to starting state

I've been coding Python for little over 6 months now. I am self taught and I would like to ask for some help for myself and also for others in my position who's been wondering if they're going about ...
3
votes
3answers
89 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 ...
0
votes
1answer
65 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 ...
1
vote
2answers
279 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
2answers
646 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: ...
4
votes
2answers
243 views

Remove matching lines from all files

I have written a Python3 program that looks for matching strings and removes them from files. ...
21
votes
2answers
37k views

Turn-based battle simulator

I am embarking on the daunting journey of learning to program on my own two feet and have created a turn-based battle simulator (think Pokémon). The idea came from here. It's very crude and could ...
4
votes
1answer
55 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
0answers
42 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 ...
1
vote
1answer
32 views

Forming a dynamic dictionary based on searched key and values pair using RAW logic and not modules of python

I am trying to create a dictionary with a file containing text based on a matched pattern. Lines containing key_str should become keys and subsequent lines not matching key_str should become values ...
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 ...
4
votes
1answer
82 views

AVL Tree implementation Based on VisualGo

I have tried implementing an AVL Tree on my own, based on visualising it. But i'm unsure how many testcases it work with, and how efficient it is. Are there any ways to make it efficient, and compact? ...
-3
votes
0answers
94 views
8
votes
1answer
132 views

A Server and Client Chatroom Using Sockets and Threading

I made a chatroom with a server and client python files, using Sockets and Threading as a project. I'm interested to acquire ...
2
votes
1answer
83 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 ...
6
votes
2answers
12k views

Expression calculator in Python

This calculator accepts four operators: +, -, *, /, and works with parentheses. Feedback on how I could make it easier to read and or more effective would be much appreciated. This is the first time ...
1
vote
1answer
72 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 ...
3
votes
3answers
7k views

Python login system for a dice game

This is a finished login system where 2 players have to enter their username and password to proceed onto the game. The usernames and passwords are stored in a text file in this format...
2
votes
0answers
41 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 ...
1
vote
1answer
43 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: ...
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 ...
11
votes
9answers
66k views

Find the repeated elements in a list

You are given an array of n+2 elements. All elements of the array are in range 1 to n. All elements occur once except two numbers, which occur twice. Your task is to find the two repeating numbers. ...
1
vote
1answer
76 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 ...
4
votes
1answer
85 views

Function for accessing and searching dictionaries using /slashed/paths (like xpath)

I have some data being returned to me in the form of a deeply nested Dict and I need to parse multiple values from it which may or may not be there. I saw the dpath ...
4
votes
2answers
13k views

8-Puzzle using A* and Manhattan Distance

I have developed this 8-puzzle solver using A* with manhattan distance. Appreciate if you can help/guide me regarding: 1. Improving the readability and optimization of the code. 2. I am using sort to ...
0
votes
1answer
82 views
0
votes
0answers
21 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: ...
1
vote
1answer
36 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 ...
3
votes
1answer
62 views

Theory-based quiz grader using similarity

I wrote a fairly simple program that grades theory-based quizzes. It is fairly straightforward. I would love to get insights and ideas on how it might be improved. ...
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 ...
2
votes
1answer
81 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 ...
2
votes
0answers
67 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
20 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 ...
3
votes
1answer
62 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....
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
77 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 ...

1
2 3 4 5
98