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
vote
0answers
26 views

Rhyming dictionary

I made a kivy app to find the rhyming words for a word entered by the user. It displays all the rhyming words as OneLineListItems in a kivy ...
3
votes
0answers
26 views

Let's get random, extending Python's base random class

So Python's base random class uses the Mersenne Twister as its base for seeded random number generation. If available, it can use /urandom/, but that is beside the ...
2
votes
0answers
18 views

Python: token request, SQL user fetch and API calls (version 2)

My original question is here Python: token request, SQL user fetch and API calls and as per the comments, I have since refactored as much as code as I think is sensible so was looking for feedback on ...
1
vote
2answers
58 views

Python: functions vs methods vs classes for simple cases

I have the following file that is included in others. I realise I need to put in try/except but for the purposes of this question, the below should suffice We're ...
0
votes
1answer
53 views

Python: token request, SQL user fetch and API calls

I have the files as below. What I'm looking for is some feedback with regards to security, reliability, maintenance, scaling and performance. What is going on? Make a request to get a token to access ...
-1
votes
1answer
35 views

Python: iterating with .items() or not? [closed]

I have this code for endpoint in endpoints: if key in endpoints[endpoint]['keys']: yield endpoint pylint suggests ...
1
vote
1answer
27 views

Calculate how many categories I can construct

I would appreciate to have your opinion on this code and whether I can refactor it and make it cleaner. I don't like the fact that I have 3 nested for loops, which ...
1
vote
0answers
33 views

Python: How to best create a dictionary from another dictionary in a library

I have the following code which builds up a dictionary of endpoints that I iterate through later on. Is this the cleanest, most scalable and performant way? I was thinking of adding a list as a key to ...
0
votes
0answers
27 views

Sim Registration Script for access to Internet

Details: Based on the input parameter to return corresponding output which is needed for setting & accessing Internet over interface [ppp0]. If the SIM is registered[ status = 1]. This script will ...
7
votes
4answers
254 views

Python: Class to calculate different variables of a projectile motion with angle, velocity (+ initial height) (first OOP program)

I'd like to hear your constructive criticisms about my first OOP project. I explain more what I actually do in the code's comments, and I tried to be quite explanatory with names etc. ...
2
votes
0answers
34 views

Simple DataFrame class in Python

I'm quite new to Python and as practice, I decided to program a prototype of a DataFrame library similar to Pandas. A DataFrame is simply a table with named columns, each of these columns is called a ...
0
votes
1answer
61 views

Extract matrices from hierarchical file structure

I have a set of JSON files stored in a folder; the folder structure is as follows: Main_folder ----F1 -----I1 ------X.json -----I2 -------X.json . . . . . . In all,...
0
votes
0answers
26 views

Script to fix linkage done with #pragma comment(lib, "a.lib) for Visual Studio project

I have a legacy project that has a lot of linkage done using #pragma comment(lib, "libname.lib"). Moreover, some projects define linker directives in ...
0
votes
0answers
31 views

A more transparent way to get the Windows API current text cursor position using Python

I've got this code, to display the current text cursor position of the last printed character on the terminal screen. It's using ctypes to get the (old non VT) ...
1
vote
0answers
30 views

Unit tests coverage of functools extension library

A few days ago I requested a review of my functools extension library. Since I did not have any unit tests for it, I started writing some for the revised version of this library. I'd like some ...
0
votes
0answers
46 views

Efficient way to build random undirected graphs without self loops given total number of graph nodes and associated node degree

I wrote an algorithm to build 1000 different random graphs given number of nodes and node degree. Node degree is maintained between the random graphs. I am building these random graphs to input to a ...
4
votes
2answers
516 views

Rock, Paper Scissors game using Python

This is a simple rock, paper scissors game I attempted as part of the Automate the Boring Stuff with Python course on Udemy. The scope of the game is for the user to enter a valid input, the system ...
-1
votes
1answer
82 views

Python: select n of each type from ordered dict

I have a for loop that contains multiple if -conditions. The speed of this function is not critical for my application at the moment but I'd like to learn and have a few tips how to optimize my code ...
2
votes
1answer
32 views

SMTP emailing library

Some time ago, I implemented an emailing library to simplify sending emails for several web applications and daemons. As usual, I am interested in improving my code. ...
2
votes
0answers
83 views

Can we make a worse automatic card shuffling machine?

So I've been droodling on a blackjack project, and one of the issues we need to solve is how to shuffle the cards. I've implemented a method that simulates hand shuffling (E.g split the shoe (either 2,...
4
votes
2answers
94 views

Rotating a matrix clockwise by one element without any libraries (Python 3.9)

The question is as follows: Rotate an NxN matrix clockwise by one element and display the new matrix. For example, if ...
3
votes
2answers
59 views

Cleaning a game logs list to find the frequent action triplets and the busy user

I have these game logs which I need to clean, process and find the frequency of game actions. These game actions should be a triplet. In the below given list, ...
1
vote
0answers
38 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 ...
6
votes
4answers
875 views

Clean up Python function with too many if/else statements

I have a working function with too many if/else statements (pylint). The code works but it's not good. I try to improve it but I have some tunnelvision. Can someone ...
2
votes
1answer
84 views

My code creates a soundboard that can assign a sound to a key on a keyboard while listening to keyboard strokes in parallel

My code works but I am looking for an efficient way to implement the idea with out having to repeat the same code block inside the function Recin() (record Input function is stated in the code) in ...
2
votes
2answers
494 views

Find month with minimum net price change

Question: The interns at Amazon were asked to review the company's stock value over a period. Given the stock prices of n months, the net price change for the \$i^{...
3
votes
2answers
231 views

List comprehension : Add new element in a list

I have a list and I want to made some manipulation on it. This my list : ...
5
votes
1answer
349 views

Simple IP address subnet calculator

In this task I had to create simple IP address / subnet calculator in Python. I'm just wondering how you see this problem. There is my code: ...
4
votes
1answer
125 views

Functools extension library

I wrote a utility library inspired by functools that adds some common operations on functions I frequently use in my projects. As usual I'd appreciate any feed back....
1
vote
0answers
19 views

Logistic Regression on Titanic Dataset - Sklearn

The goal of my program is to calculate the chances of a person to survive during Titanic accident, after receiving information such as person's age, class, sex, etc. There's a dataset full of ...
0
votes
2answers
125 views

for loop Optimization [closed]

I have a sample Json as mentioned below ...
8
votes
3answers
351 views

Implementing a efficient Infix to Postfix using Shunting-yard algorithm

I was trying to implement an efficient (in terms of size of code (such as using one liners) and time and memory-efficient) of Infix to Postfix in python without the use of any external modules i.e ...
7
votes
2answers
603 views

First Hangman Game. Need Honest Opinion

Please provide your honest feedback. Thanks Doing Angela Yu's 100 days of code. Have not seen the videos on this section yet. This is just my attempt. here is the link to run the code. Hangman game <...
1
vote
1answer
58 views

Python: Generate SHA3 hashes for files with custom rate and capacity values

I am working on a project which requires comparing the performance of SHA3 on different values of rate and capacity. I have implemented the same in Python and my program works fine, however, the ...
2
votes
4answers
77 views

The user-facing part of the code base, using Python's argparse package

This question is a sequel to one I asked the other day. The previous question examined the core of my repo; this one examines the user-facing part. If you're curious to see what the repo as a whole is ...
2
votes
1answer
44 views

Decorator for forward type hint resolution

Background I frequently develop ORM libraries using the peewee framework. On one particularly large ORM library, representing a proprietary data format, I have a lot of coupled ORM models representing ...
2
votes
0answers
61 views

OOP Blackjack in Python 3.9.9

I've noticed I'm not the first to post this topic. As a matter of fact, I have taken some inspiration from Victor Nguyen Bao's post to help structure my code. Here's the link to his code: Structured ...
0
votes
0answers
36 views

Time representation [migrated]

I have the class Time, its purpose is to store time in seconds but for user to use "1:2:3" format, I need to be able to do algebraic operation on it instances, since the whole overriding is ...
2
votes
1answer
56 views

Refine Linked List Implementation in Python (pop, insert methods)

I've recently learned how to implement linked list in Python. Can anyone help me to refine my code of implementing methods 'insert()', and 'pop()'. pop(pos) - remove and return item at position pos. ...
2
votes
2answers
54 views

Python dice adventure game

I have been dipping my toe into programming for a number of years, mainly following tutorials and then giving up when trying to build my own projects. This time I bit the bullet and didn't give in and ...
2
votes
2answers
60 views

A Python script to install a number of useful programs and packages on a fresh Linux-based device

I work with Linux-based devices, and, both at work and in my personal life, it's necessary to wipe these devices every so often - sometimes as frequently as multiple times per week. In this context, ...
1
vote
1answer
84 views

Boolean expression evaluation for user input using evil eval

The following code is a module that evaluates boolean expressions, which are entered through an unauthorized web API. The exposed function of the library being used is ...
1
vote
1answer
53 views

Linear Regression in Scikit_learn

I have 2 datasets (one for training and the other for testing) containing information about days temperature and humidity; My programm should process the training dataset and find a relation between ...
1
vote
1answer
60 views

Multi-step aggregation of cryptocurrency data with high precision

My goal is to aggregate a DataFrame with several million rows including Decimal('...') columns without any precision loss. My ...
3
votes
2answers
80 views

API client to retrieve traffic news

I reverse engineered the API from adac.de and wrote a client to query it for traffic news (constructions sites, traffic jams etc.). Here 's what I came up with: ...
1
vote
2answers
46 views

Get conjugations of French verbs using a HTML parser

I'm trying to create a program in python to automatically get conjugations of French verbs. I do not want to hard-code any conjugations, and I could not find an API, so I decided to write a program ...
5
votes
2answers
377 views

Mine sweeping game for the terminal

Over the holidays I was bored due to lockdown and implemented a mine sweeping game for the terminal. Any feedback is welcome. ...
3
votes
2answers
82 views

Find a digit at a specific position of a number

Is there a better approach to find a digit at a position in a number instead of converting it to a string, I feel what I have done doesn't seem best practice and arithmetic! ...
1
vote
1answer
101 views

print 10x10 random numbers from 1 to 3 table

The code below will print a 10x10 table of random numbers between 1-3. Is there something to make the code faster? Can the code be made more readable? ...
2
votes
1answer
77 views

Password Hasher (obviously not secure)

How the program works is that the user sends 2 inputs over (userinput and passwordinput). These are compared against the ...

1
2 3 4 5
99