Questions tagged [python]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.

Filter by
Sorted by
Tagged with
1
vote
2answers
42 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: ...
2
votes
0answers
64 views

Junior Dev Self-taught Resume Project

I've been learning Python now for 3 months as I find it really interesting to code. I want to be able to apply for junior dev positions and as I have no formal education I thought I'd make a project ...
5
votes
1answer
138 views

Multiplayer card game “Hearts” with OOP in Python

To practice Object-Oriented Python and learning how to write tests, I found an exercise and solved it as below(all classes are put in one block of code to make the question a little bit more readable):...
1
vote
1answer
29 views

PyQt 5 CheckBox State Efficient wAy

Firstly, have a good day to all, I've been trying to learn PyQt5 nowadays. I wrote a code about check box state changing depends on other check box. It looks work. I wonder your feed back. Thank you ...
4
votes
0answers
50 views

Postgres Shopping Database using Python

So I have just started to work with SQL and I have tested my script and is working very well when it comes to my database. The database is used for shopping. What I mean by that is that I scrape a ...
4
votes
1answer
67 views

Simple python for playing Hangman

I'm learning python (started about 30 hours ago) and my son asked if I could make a hangman game. Well, okay, I'll give that a try. I'm sure this code is crap, but I'll never learn if I don't ask ...
2
votes
0answers
50 views

Google Foobar -Expanding Nebula - Code takes too long

So I'm on level 5 of Google Foobar, and the Question is Expanding Nebula. It goes as follows : Expanding Nebula You've escaped Commander Lambda's exploding space station along with numerous escape ...
1
vote
1answer
40 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
54 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. Here is the question: Alice is playing an arcade game and wants to climb to the top of the leaderboard and ...
2
votes
0answers
33 views

Basic flask template with sessions

This Flask app, which makes use of SQLAlchemy, a MySQL server which is only reachable via SSH and Flask-Login, is the base on which I want to write an application which has login protected pages. ...
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 ...
1
vote
0answers
45 views

Celery tasks and Flask application factory

I am implementing a few Celery background tasks (e.g sending an email, subscribing someone to an Audience via Mailchimp API, etc.) and my project relies on a Flask application factory. Now, I am ...
4
votes
3answers
298 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 ...
4
votes
1answer
145 views

Jupyter notebook style help + code suggestions for pandas

I wanted to open source some code to scrape and analyze publicly-filed stock buys and sells from U.S. senators. I'm not familiar with code style for Jupyter notebooks or pandas in general. Would it be ...
1
vote
1answer
43 views

Runtime Error in Minion Game problem (HackerRank)

Below is my function to solve the Minion Game problem on HackerRank along with the problem description. It works wonderfully with regular-length strings, like 'banana', but when it comes to really ...
2
votes
1answer
66 views

Add 2 doubles in string format

Add 2 strings representing 2 doubles, return the sum of the 2 doubles in string format. Please review my code. Is there a cleaner way of writing the code where we have to add the 2 doubles digit by ...
-3
votes
1answer
49 views

Extremely simple python password generator [closed]

I tried to make a password generator and at first it works as intended, generating a password with lowercase, uppercase and special characters but I can only generate passwords of up to 19 characters ...
1
vote
1answer
63 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
1answer
87 views

friendship program using graph type python/algorithm

I have created a program but I feel the def common(friendships, person1, person2) function can be more efficient, if anyone has any good idea how I can improve it I ...
3
votes
0answers
57 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\...
4
votes
2answers
133 views

Is this calculator written in Python clean/good?

As a beginner I wrote my first program (calculator) with Python and as far as functionality is concerned it just works fine but I have some concerns about one thing at the end of the code. Under ...
3
votes
2answers
55 views

Simple Compute Pay Function

Can this be made any simpler/shorter/more efficient? This function will compute paycheck amount according to hours worked and rate per hour. ...
2
votes
1answer
82 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
63 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
54 views

Wrapping an asynchronous generator in Python

Since Python 3.6 and PEP 525 one can use asynchronous generator: ...
2
votes
0answers
33 views

Scraping local news sites

This is my first Python web scraper (and overall my first Python project). I am also relatively new to OOP but do understand its core fundamentals. The script below scrapes two local news sites for ...
1
vote
0answers
28 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 ...
3
votes
1answer
55 views

Python Binary Search

My take on a binary search algorithm without research or knowledge of an efficient one. It would be appreciated if one could show me an efficient way to do it using recursion or a more pythonic ...
0
votes
2answers
33 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 ...
3
votes
1answer
29 views

Simple Vigenere Cipher In Python

I'm a relatively new programmer. I've made a simple Vigenere cipher program. It takes three arguments and acts on a file. I have made some of the steps more "explict" for myself by using more lists ...
1
vote
1answer
51 views

SQLite and Python: commit once every 10 seconds maximum, and not after every client request

In a Python Bottle server using SQLite, I noticed that doing a DB commit after each INSERT is not efficient: it can use 100ms after each client request. Thus I wanted to improve this in How to commit ...
5
votes
3answers
121 views

Longest Peak without backtracking

The goal is to find the longest peak in a sequence of numbers. A peak is defined to be a strictly increasing elements until a tip is found and then a strictly decreasing elements. e.g. (1): 3, 2, 1, ...
4
votes
2answers
245 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

Total beginner Tic Tac Toe game in Python

I've decided to learn Python about 2 weeks ago, been going through various books and videos, and I've decided to try my hand at programming a Tic Tac Toe game. I was somewhat successful (it doesn't ...
1
vote
1answer
32 views

Iterate over a short list, pairing the elements with the sequential elements of a longer list [closed]

I am a relatively new programmer. I am trying to use iter and cycle to cycle over a list (key) and 'pair' each item with each ...
1
vote
1answer
61 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 ...
4
votes
2answers
119 views

Polynomial regression with Gradient Descent: Python

Just for the sake of practice, I've decided to write a code for polynomial regression with Gradient Descent Code: ...
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
121 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
2answers
28 views

Python function to find specific regex in the text of an XML document

I'm writing a code that, starting from an XML file: stores the index of child elements of a tag and the child elements as key, values in a dictionary (function ...
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
96 views

Deep len, Python

Goal: find total number of elements in a nested iterable of arbitrary depth. My shot: ...
2
votes
0answers
66 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
82 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 ...
2
votes
0answers
31 views

CLI Argument Value Management

Background I've recently made a contribution to an open source project, ledger-autosync, which is a CLI "to pull down transactions from your bank and create ledger ...
1
vote
0answers
34 views

Optimizing the Cython code for solving system of ODEs

I am trying to optimize this code for solving a system of ODE. It seems Cython does not speed up the code compared to code using ...
6
votes
1answer
89 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. ...