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
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
86 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
85 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
195 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
112 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
85 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
91 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 ...
0
votes
1answer
34 views

Making list of errors from file

So I have a file of errors, there default meanings and also it's hierarchy in terms of indentation ...
0
votes
3answers
71 views

Print greatest factor if it is same for both numbers

Take input n1 and n2 and check if they have the same greatest factor. If they do, print that factor. If they don't, print "No". example: input: 6 9 output: 3 input: 15 27 output: No ...
2
votes
2answers
85 views

Serializing (nested) data structures in a human-readable format with all bugs fixed

See Serializing (nested) data structures in a human-readable format for more details. This is the latest version, I have fixed all bugs and now this piece of code works completely as intended. And I ...
-1
votes
4answers
88 views

Python weighted choosing that works with very large numbers

I have written a function to choose randomly with weights from very large data sets in which the weight of elements can be several thousands. The input of the function is a flat ...
4
votes
2answers
792 views

Serializing (nested) data structures in a human-readable format

I am reinventing the wheel to write a function that serializes a (nested) data structure human readably. The default output is deliberately similar to that of ...
3
votes
2answers
96 views

Python program to find all possible ways an integer num can be expressed as sum of integers between 1 and lim

This is a Python program that finds all possible ways a positive integer num can be expressed a sum of a number of integers between 1 and ...
7
votes
3answers
1k views

Levenshtein distance using dynamic programming in Python 3

I had to implement a function for getting the Levenshtein distance of two strings for a problem. It linked to the Wikipedia Article for Levenshtein distance and mentioned I can use the dynamic ...
0
votes
1answer
56 views

Indexing base class attribute overrides: cls -> value

I want to be able to create a hierarchy of classes and efficiently lookup them by common class attribute value. So far I've come up with this solution: ...
2
votes
1answer
120 views

Implementing histogram in python

I was trying to implement my own version of matplotlib's hist function and I came up with this: ...
3
votes
0answers
66 views

Python program that analyzes a corpus for randomword generation

I play a lot of old-school western CRPGs, and most of them (if not all) require the player to generate an avatar at the start of a new game, including naming the character (with names that will never ...
2
votes
1answer
50 views

Find the closest match to a string [closed]

Input The first line of input contains a string s: the word misspelled by your partner. Assume that your partner did not add or remove any letters; they only replaced letters with incorrect ones. The ...
2
votes
1answer
78 views

Divide array into three disjoint sets with equal sum

Problem definition : Array partition problem Given an array of positive integers, divide it into three disjoint subsets having equal sum. These disjoint sets cover the complete array. Example Input: [...
1
vote
1answer
235 views

How to speed up the search by patterns matching and modifying a DataFrame

I need to classify URLs from a DataFrame and modify it by exact match and contains conditions: ...
2
votes
1answer
101 views

Drug Analyzer challenge

What do I need help with? I'm doing the challenge below, in which I need to increase code performance. It's currently at 63% and I need to increase it to at least 71% however I can't optimize more ...
2
votes
0answers
54 views

Asynchronous line-based communication with an external program

As part of a larger project, I've written the following code for interacting with git-annex's addurl command in batch mode. ...
9
votes
3answers
3k views

Two player dice roll game

This is a finished project where 2 players each roll 2 dice. If the sum of the number that a player has rolled is even, then 10 is added to their score; if the sum of their 2 rolls isn't even then 5 ...
15
votes
5answers
2k views

Comma Code, Project from "Automate the Boring Stuff with Python"

I'm a newbie. I'm at Chapter 4 of Automate the Boring Stuff with Python. Comma Code Say you have a list value like this: ...
0
votes
0answers
20 views

Library To Help Looping Redesign [duplicate]

I have changed the design of my library to help looping with generators. The new version uses iterables which allow a data structure or generator to be passed to the functions. The iterators are then ...
2
votes
2answers
61 views

Library to Help Loop with Generators

I found I need to loop through a list to create a brute force algorithm. Therefore, I decided to make a library, but to generalize the result by using a generator. There are three cases which is every ...
5
votes
1answer
87 views

Join Lines (considering `-` at the end of lines)

Normally when a line ends with -, it means it should be joined differently. For example, if we join lines of: ...
2
votes
1answer
397 views

Python 3 Playfair cipher encrypter and decrypter

I have written a Python 3 program that can encrypt and decrypt Playfair cipher, though I know it has been implemented countless times, none of the scripts I have seen so far(e.g. https://codegolf....
5
votes
2answers
496 views

Get the Firefox Default Profile

To get the Firefox default profile, I am using the following program. ...
1
vote
1answer
82 views

Hashing with python optimization, hashlib and multiprocessing

I am looking to get any type of improvement, I want to be able to hash a list of 'blocks' aka strings and check if hashes match per block, if you can help me with that, currently reading and writing ...
8
votes
3answers
3k views

Calculate evapotranspiration

I am trying to create a code for the Basic evapotranspiration equation by Hargreaves. I have attached a screenshot of the equation to be replicated. I want to create a class wherein I can input data ...
10
votes
1answer
806 views

Printing a diamond shape in ASCII

...
2
votes
1answer
59 views

Counting Restaurant Orders

I created a computer program which takes a list of names and dishes chosen. The program then counts how many dishes and which dish are ordered. The result is then returned from a function. The ...
3
votes
1answer
65 views

Lightweight interface implementation in Python 3 using abstract classes

Here is my take at a lightweight interface implementation, where I focus on discoverability of suitable classes from strings (for simplicity, class name is used as an id). Each interface has it's own &...
3
votes
2answers
67 views

Staff Manager Windows APP -Python

Below there is a full code for my app Staff Manager. The app does allow basic staff management, like adding, removing or changing details of employees. As it is one of my first GUI apps and I am self-...
0
votes
0answers
25 views

Pass-through conditional logging

I'm using the logging module in python and I need a function or class method which logs only if some condition is false, similar to ...
4
votes
3answers
68 views

Python 3 Multi-connection downloader

I have written a fully functional simple command line multi-connection downloader, written in Python 3, using just threading, ...
0
votes
1answer
52 views

Convert string to 10 character string with leading zeros if necessary

I have the below data and am obtaining the expected output column for it. ...
1
vote
0answers
62 views

First attempt at chess in Python #2

Almost a month ago I asked for some review of my first attempt at Chess in Python, with the main goal being to start learning inheritance in Python. It can be found here: First attempt at chess in ...
1
vote
1answer
41 views

Python code to check the null values in excel files

I want to check null values in excel files where there are many sub folders. I have wrote a python code to check the null values in excel files in each and every folder and the code was working fine ...
1
vote
0answers
23 views

Wrangling and reading several xlsx files from sftp server and concatenating them into a single dataframe

Please find below my code. Any recommendations/suggestions on how to improve it and make it more readable will be hugely appreciated. I've tried to comment it as much as possible so everyone can ...
5
votes
1answer
83 views

The python code simulates an environment of a disease and calculates how many people get infected

The python code simulates an environment of an X number of persons with an Y number of places they can go to, puts the persons randomly in the places and calculates how many persons get infected, die ...
2
votes
1answer
51 views

Garden simulator [closed]

I tried to write the program so that it runs without error but I want to improve the program so that it follows the Single Responsibility Principle. What changes can I make to improve this program? I ...
3
votes
2answers
107 views

Prime number finder in Python3

The problem I am working towards improving my Python coding. I am checking that I am doing the best in terms of the Python code, not necessarily the algorithms. Having looked at one of my previous ...
4
votes
3answers
100 views

Template For a CLI Application

I have written the following cli tool. ...

1 2
3
4 5
99