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
1answer
60 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
43 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
67 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
225 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
11 views

normalizing django models

i try to make an app for a mobile store ...
2
votes
2answers
45 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 ...
2
votes
1answer
74 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
39 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
319 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
66 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
73 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 ...
3
votes
1answer
55 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\...
3
votes
1answer
105 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 ...
4
votes
1answer
72 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 ...
4
votes
1answer
69 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 ...
5
votes
2answers
258 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
63 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
160 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
98 views

Deep len, Python

Goal: find total number of elements in a nested iterable of arbitrary depth. My shot: ...
2
votes
0answers
83 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
84 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 ...
5
votes
1answer
105 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
49 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
136 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:...
3
votes
1answer
62 views

Data conversion utility with group-wise serialization

Introduction I'm new to Pandas. I'm trying to write a vectorized converter for the situation described in What is an efficient ways to parse a bar separated usr file in Python . All code presented ...
3
votes
2answers
44 views

Converting a natural number to a permutation matrix in Python. How to speed it up perhaps avoiding messing around with lists, sets and dicts?

It is something a bit complex to explain here, but the code bellow takes a 128-bit number and converts it into a permutation matrix, a beast which I have already faced before. The matrix is ...
2
votes
3answers
108 views

Efficiently convert 60 GB JSON file to a csv file

Description Simply take a JSON file as input and convert the data in it into a CSV file. I won't describe the functionality in too much detail since I have reasonable docstrings for that. As you can ...
2
votes
0answers
82 views

Tkinter widget for managing .ini files through ConfigParser

A tkinter widget for reading/editing .ini files Dynamically generates a form based on the contents of the passed .ini file. Why make this? I made this as a backend for a larger project; I wanted my ...
3
votes
1answer
53 views

How to efficiently (fast) calculate the transpose of a *permutation matrix* in Python3?

The permutation matrix is represented as a list of positive integers, plus zero. The number indicates the position of the 1 in that row, e.g. a number zero would mean that the 1 is in the right-most ...
2
votes
1answer
80 views

Calculate your total happiness, which depends on the integers in the given sets [closed]

I am a beginner in programming. And I am learning python as my first language. I went on to do some challenges on HackerRank and stumbled upon this problem. The problem goes like this: There is an ...
1
vote
0answers
28 views

Modelling articals and authors in Django

I need to understand if the way I am modelling data in a Django application is correct. The idea is of a news site that has sources, authors and articles. I want: ...
5
votes
1answer
35 views

Applying gaussian blur on RGBA images

I designed the code and it works quite well for images of lower res. However my program takes a lot of time and ram to display higher res images (occupies 2GB RAM for 4k images and takes 20 minutes). ...
2
votes
1answer
36 views

Merge Sort Implementation Efficiency In Python

I wasn't able to find a standardized source for a working example of Merge Sort. Each learning site had a slightly different take on the algorithm implementation, disregarding the bottom-top ...
2
votes
1answer
32 views

What is the optimal way to retrieve a list of sorted dates in a list of sorted periods in python?

Suppose I have a list with N sorted dates and M non-overlapping sorted periods with start date, end date (inclusive), and a tax rate for example. I have to make an efficient algorithm retrieve all tax ...
-1
votes
2answers
109 views

Collect a list of unique “Origin” headers from a repeated URL request [closed]

I want to create a list of the different response headers I get when querying an URL, I succeeded in doing this this way: ...
3
votes
1answer
43 views

Insertion Sort Implementation Efficiency

Is my approach to insertion Sort in Python efficient? What can be improved efficiency wise? ...
2
votes
2answers
78 views

Resolving Paths relative to script file, independent of calling location

Idea Consider the following snippet: ...
3
votes
1answer
93 views

Tic Tac Toe with ASCII art

I have written a simple Tic Tac Toe game using some ASCII art. Is there anything I can do to improve upon the logic and structure of the program? ...
1
vote
2answers
87 views

Initial Mass Function for young star clusters and disk field stars

I hope you can help with improving my code. I am defining a function which draws out elements of a certain mass, one by one, from a distribution constrained by the function ...

1
3 4
5
6 7
83