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

Check if two lists are permutations of the one another ( Improvement)

Task: . Complete the following function that determines if two lists contain the same elements, but not necessarily in the same order. The function would return true if the first list contains 5, 1, 0,...
0
votes
2answers
55 views

HashMap Implementation (dictionary) in Python

I attempted making a hashmap in python, and it was harder, due to some limitations but this is my version of dictionaries in python. Are there any way to simplify or do the same thing in less code ...
16
votes
11answers
3k views

Check if array has the same number of even and odd values in Python

Task: Complete the following function that determines if the number of even and odd values in an list of Integers is the same. ...
-4
votes
1answer
67 views

Finding The Largest Digit in a Number using a Recursive Function in Python [closed]

I tried it using the code given below. ...
3
votes
0answers
76 views

Check the organization and code style of a small Python project

Could you look at my code for the completed training project of the Python Hangman game and tell me where you can improve the code style? Code on GitHub ...
4
votes
2answers
189 views

hangman with ten chances

So this is the code I wrote for hangman in python. I want to know of can shorten this code more further and make it look more professional ...
4
votes
1answer
68 views

Life and death model in python

The basic idea of the code is that agents come into the world, they age and then die. I want to keep track of who is dead and who is alive. Eventually, they will do more things but I think there ...
8
votes
1answer
186 views

Clone of mobile game Ballz

I have made a clone of the mobile game Ballz, and it works quite well. However, there are a few problems: Performance. When I have more than 50 balls in the game, the FPS dips from 60. I am unsure ...
3
votes
1answer
85 views

Python class inheritance - creating pythonic naming, logic and functions

Motivation I have been trying to work on my first bigger scale Python project, however I am struggling to create pythonic solutions. Instead some of the functions (and especially the naming) I've ...
6
votes
2answers
265 views

LazyEnum with validation

Motivation In the standard Python library enum, a subclass of Enum would create all its members upon class creation. This can ...
4
votes
0answers
155 views

Deep map, Python

Goal: apply fn to every element of an arbitrarily nested iterable (tuple, list, dict, np.ndarray), including to iterables. Ex: ...
2
votes
0answers
29 views

Handling failures in DB transactions

This code is meant to retry the db operation when a DB connection breaks: OperationalError. A transaction can fail for example when a db is being restarted and a commit fails. Or when a network error ...
10
votes
3answers
2k views

Simple Sudoku Solver in Python

This is my naive approach on implementing a Sudoku solver, which is okay for simple Sudokus like this: ...
1
vote
2answers
62 views

Find 2 numbers that multiply to a number and add to another number

Here is my code, however, I am unsure whether it is the fastest way to achieve this objective. ...
4
votes
2answers
93 views

Ising model simulation using metropolis algorithm

I am new to this community; I have tried my best to respect the policy of the community. I have written the Monte Carlo metropolis algorithm for the ising model. I want to optimize the code. I have ...
0
votes
1answer
58 views

A Credit Payment Calculator

So I've attempted this project from hyperskills where you're asked to make a calculator script that can calculate annuity and differentiated payments given that 3 of 4 values are known. I think i went ...
0
votes
1answer
41 views

Algorithm Divisible Sum Pairs

I did the Divisible Sum Pairs problem on HackerRank input: n is length of array ar, k is an integer value. a pair is define only if ar[i]+ar[j] is dividable by k where i < j. Problem: find ...
1
vote
0answers
26 views

Python3 BFS Flood Fill with Deque and 2D Indexing

I'm currently in a programming competition where time is key, therefore I'm trying to optimize my solution as much as possible. I am trying to implement a BFS Flood Fill solution on a map size of ...
5
votes
2answers
65 views

Number Base Conversion Problem Generator

A program that generates questions to train your number base conversion skills. This program is made to ask questions about octet, binary and hexadecimal. No other bases. It first asks a series of ...
7
votes
1answer
221 views

Decorator to cache a function result for some time

I recently played around with a script that got some data from the Google API. As I didn't want to spam requests at the service (and potentially get blocked), I made this decorator, which caches the ...
3
votes
1answer
58 views

Finding tags and changing id attributes

I have the following code which works fine but the execution time is more which I want to reduce. I guess this happens since each file is opened and then the operation is performed. Is there a way to ...
1
vote
0answers
21 views

Python3.x imports ordering [closed]

I have the following imports ...
0
votes
3answers
109 views

Get methods in module, Python

Goal: extract methods/functions defined in module. This excludes: Imports Lambda methods Magic methods Builtin methods Class methods Classes Non-original definitions (i.e. function assignments, ...
1
vote
0answers
10 views

normalizing django models

i try to make an app for a mobile store ...
1
vote
2answers
44 views

Python 3.6+ Conventions for fetching paginated data

I find myself often encountering a use case where I need to fetch paginated data, where I need all of the data. Currently I use something similar to below to handle these cases: ...
1
vote
1answer
41 views

Multiplying by certain elementary symmetric polynomials

Let me preface this with saying that it's probably not necessary to understand all the math behind this to review my code. Unless you have a lot of spare time or a very strong interest I also wouldn't ...
1
vote
1answer
72 views

Binary Search implementation: HackerRank - Climbing the Leaderboard

My code passes 11 out of 12 test cases. I was wondering where I can improve my code. NOTE: This code needs performance improvement, as it is working for most of the cases. To mu knowledge it would ...
2
votes
1answer
47 views

Small script to update an external HDD every night at 23 in the background

This is a small script to update an external HDD, every night at 23:00, in the background. Can you tell me how I can improve it? What section in this code can be written as a class? Maybe the ...
1
vote
0answers
38 views

Converting multiple HTML files to csv lowers down the speed

New to python. I am converting multiple html files to csv. Developed a full code. It can easily convert 50+ files at a time but after 200+ files, the code takes too much time and with 1000s to ...
4
votes
3answers
318 views

Crawl a website and download records

I am new to Python. Amateur, enthusiast and learner. I have developed code which visits one particular website. Crawls through it to reach a certain repository, downloads the records from there to the ...
1
vote
1answer
65 views

Simulating a Rock, Paper, Scissors Game - Flexible

Today I learnt the basics of OOP. I have tried to apply them to this Rock-Paper-Scissors project. However I'm still a beginner, and so I feel my code can be improved. Are there any tips, trick or ...
3
votes
0answers
72 views

Coffee machine in Python 3

I've been struggling with python OOP. I've gone through the basics but I'm struggling with implementing them. So I've decided to create something small everyday while in quarantine to get more ...
2
votes
1answer
54 views

Use Python Enum to implement residue ring and multiplicative residue group

I have implemented the integer residue ring \$ \mathbb{Z}/m\mathbb{Z} \$ and the integer multiplicative residue group \$ (\mathbb{Z}/m\mathbb{Z})^* \$. Functionalities include: In \$ \mathbb{Z}/m\...
2
votes
1answer
101 views

I made a Rock paper scissors game with Python 3.8

If you could rate my code, 1-10. What will it be and provide reasoning on why you gave that answer, i feel like i could of written this code better but i don't know what i am missing or what i could ...
3
votes
1answer
69 views

Webscraping With Selenium - a Course Downloader and Sorter

I've been working on a program that automates the painful task of downloading each file from a website for courses one by one and sorting them using python. This is my first python webscraping project ...
3
votes
1answer
67 views

Wrapping an asynchronous generator in Python

Since Python 3.6 and PEP 525 one can use asynchronous generator: ...
1
vote
0answers
31 views

Implementing Doubly Linked List in Python

My take on Doubly Linked List in Python. Is there a more efficient and compact way to do this? Are there any bugs in my program if so how can i fix it? PS: I'm a beginner in Object Oriented ...
0
votes
2answers
36 views

Looking to simplify my first python Rock, paper, Scissors project

I recently (Yesterday) started working with python and my goal is to not use any tutorials etc where I have to follow along and make a small project. My first project I was recommended to do was a ...
4
votes
2answers
253 views

More elegant way to count anagrams in Python?

Question I feel like my code could be more elegant/more pythonic/faster, but I can't think of too much more to improve. So, I've come to the internet to see what more can be done with standard python....
1
vote
1answer
62 views

Getting hexagonal arrays of dots arranged in this spiral pattern

Answers to this explain why I can't reliably get int type arrays. While there are some workarounds I have a hunch there's a better, cleaner or otherwise "less ...
1
vote
0answers
34 views

Feedback on hangman game about coding style

I have been playing around with python and made myself a hangman game. Questions: How readable my code is? Are there any logical errors that I'm not aware of? How to improve it? Is there a better ...
5
votes
1answer
143 views

Rock, paper, scissors in Python 3

I am new to Python (and to programming). I tried to implement this game in Python and took some help from the code reviews of similar questions posted on this website. ...
1
vote
0answers
37 views

File organizer based on extensions

I'm still new to programming and I'm not confident about this code. I recently created this File Organizer that organizes files in folders based on their extensions. How can I make this code cleaner? ...
3
votes
2answers
97 views

Deep len, Python

Goal: find total number of elements in a nested iterable of arbitrary depth. My shot: ...
2
votes
0answers
80 views

Generating markdown documentation for VBA code

Generating documentation for VBA code The goal of this exercise to is create an application which can read module files created in VBA project and generate markdown documentation for them. Key ...
8
votes
3answers
2k views

File Automation Using Python On Linux

A project to automate file organization in Linux using Python. I've always wanted to do this project way before I know how to code. Now that I did, I want to improve it even more. Used Language: ...
4
votes
1answer
83 views

Why is append() slower than + and is there some oversight in the map() solution which slows it down?

I was trying out some variation in implementation of a leetcode example and was surprised by the runtimes. I was expecting it would be better to use map() than ...
6
votes
1answer
92 views

Tower of Hanoi without recursion

Hi I am pretty new to programming and I would like you to give me some feedback about my code, how does it look, what could be better. Thank you. ...
3
votes
0answers
48 views

Snake game with multiple snakes

Firstly, I wrote standard snake game, then I decided to increase difficulty and made game with various snake number. My main point was to try the curses module, the second - to create game with OOP ...
3
votes
2answers
134 views

Console-based Guess the Number

I started learning Python and wrote my first program. This is a console game based on guessing the number. Can you take a look and tell me if I'm doing it right or give me any advice? Here is the code:...

1 2 3
4
5
83