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
3
votes
1answer
80 views

matplotlib fixing axis scale and alignment

There is few points In the script I don't like I think it can be improved, but I need a second opinion, here is the interactive plot I'm trying to build. here is the code with thought in comments. <...
-6
votes
0answers
19 views

Kinematics Simplification [closed]

So I created a one dimensional kinematics equation solver which has been successful, however was interested in simplifying my code. My code works once user inputs the the given variables, then boolean ...
2
votes
1answer
38 views

VanityURL checker in Python

...
2
votes
0answers
18 views

AVL Tree implementation Based on VisualGo

I have tried implementing an AVL Tree on my own, based on visualising it. But i'm unsure how many testcases it work with, and how efficient it is. Are there any ways to make it efficient, and compact? ...
1
vote
1answer
49 views

Beginner Hangman Game

Hey guys I am trying to improve my Python Programming skills, I tried to build a hangman code. I know it is not perfect but I works. I am looking for some hints or advice to improve this script. <...
0
votes
1answer
24 views

Max Contiguous Subarray: Divide and Conquer

I am conversant with Kadane's Algorithm. This is just an exercise in understanding divide and conquer as a technique. Find the maximum sum over all subarrays of ...
1
vote
1answer
34 views

Statistics function

I have created a database using Django. I have a small statistics page as shown below. Can I improve this code? View file ...
2
votes
1answer
51 views

Faster way to check if number has factor of different primes than given list of primes

im trying to get the factor prime number(s) for given number if its different than the primes that i have in a list. The number have to: dividable with any of the primes in the list should not have ...
0
votes
1answer
62 views

Image color-moment extractor [closed]

I was just wondering if there is a way to speed up the performances of this for loops in Python. I'm trying to process an image to get the color-moments without using libraries. It takes about 12sec ...
3
votes
1answer
32 views

Simple stopwatch program with tkinter

I've self-taught myself Python and have recently started learning tkinter. I made a simple stopwatch program and I wanted to know if the code is clean and written in a way that the code works ...
1
vote
1answer
37 views

2 player CLI Tic-Tac-Toe game in python

This is a fully functional code that i have just completed today. I just want to know how efficient is this. and how could i improve it or if theres any bugs that i have miss out. ...
4
votes
1answer
43 views

BST implementation (MIT OCW Runway scheduling problem) + Unit Testing in Python3

Inspired by MIT OCW (6.006)'s lecture on BSTs, I implemented them with the slight tweak where an element has to satisfy the "k-minute check" before insertion. If its value is within k of any other ...
3
votes
2answers
49 views

Web Scraping Newspapers

Wrote a python script to web scrape multiple newspapers and arrange them in their respective directories. I have completed the course Using Python to access web data on coursera and I tried to ...
2
votes
1answer
24 views

Download statements from Yahoo Finance

This is a Yahoo Finance wrapper to get income/balance statement for a stock ticker. What I have tried to do is make an abstract implementation so more features can be added easily in the future. The ...
6
votes
2answers
210 views

Plank cut-list calculator

So I've just finished my first Python module (and published on Github), with this little project I'd like to learn how to distribute my code so that other users can use it as a plug in for their own ...
0
votes
1answer
34 views

Two player tic tac toe Python

Used classes to make this simple tic tac toe game. Any improvements? ...
3
votes
2answers
84 views

Python script for ad-hoc continuous integration from Github to publish for a small group of collaborators

I'm doing a little more grad school, and for a group project I wanted us to be able to quickly share and update our project, so I coded up a Python script to handle that. As usual, I'm proud of the ...
3
votes
0answers
40 views

Improving Performance of Numba For-Loop and Matrix Multiplication for Time Integration Solver

I am writing some code that performs a simple time-history integration solver (Newmark method for structural dynamics) and I looking for some suggestions in how I can improve the performance of my ...
7
votes
2answers
288 views

Probability that Three Pieces Form a Triangle

I wrote some code to estimate the solution to the following problem: If you break a line segment at two random points, what is the probability that the new line segments can form a triangle? The ...
3
votes
1answer
52 views

Implement hash table using linear congruential probing in python

I have just read the Chapter 5 of Data Structures and Algorithms with Python. The authors implemented hash sets using linear probing. However, linear probing may result in lots of clustering. So I ...
2
votes
1answer
46 views

Snake game implemented in PyGame and Python3

I know there's already a whole bunch of similar attempts at this and I've looked at a few of them to get some tips. My main aim with this was not to write anything fancy. I wanted to create a simple ...
1
vote
0answers
30 views

Implement priority queue as min-heap in python

The standard library heapq in python doesn't support updating keys as a public method, which makes it hard to be used as a priority queue. Although the official ...
2
votes
2answers
30 views

Python Tic Tac Toe Building Block Function

Would appreciate any input on these building blocks functions of tic tac toe. ...
3
votes
2answers
45 views

Implementing a Steepest Descent Algorithm

I am teaching myself some coding, and as my first "big" project I tried implementing a Steepest Descent algorithm to minimize the Rosenbrock function: $$f(x, y) = 100 (y - x^2)^2 + (1 - x)^2$$ The ...
1
vote
1answer
20 views

PyQt5 GroupBox Layouts Feedback

I will import given code for my main QMainWindow.(I only add import sys etc. to run it) Is there a more compact way to code this lines. Output is correct for my ...
10
votes
3answers
2k views

Screenshot-to-OCR utility

I've made simple app that is able to take screenshot each -t seconds and OCR it to -o file. It's also able to take -path and OCR all images to -o file. It works pretty well thanks to tesseract ocr. ...
4
votes
2answers
108 views

Traveling salesman to find beer types from breweries

I am writing a modified travelling salesman problem recursively in Python 3.7. It has to find the best path around breweries to find the most beer types and not to exceed the ...
6
votes
1answer
66 views

Web scraper for restaurant ratings

I'm new to using type hinting in Python. I've used it for a small scraper I had to build (see code below), everything works fine and mypy gives no errors. However I'm sure there are better ways to ...
2
votes
0answers
35 views

Max Heap Implementation in Python

I decided to challenge myself to code this data structure by just seeing how it looks visually and this is what I got. I can change this easily to minheap by changing some greater than (>) operators. ...
3
votes
1answer
50 views

Python code to reiterate different files

I have written Python code to rearrange some files in a directory, create new directories and delete old ones to form the dataset in the structure that I want it. Previously, I was doing this with ...
2
votes
3answers
56 views

Pathfinding algorithm with wall destruction [closed]

The code below works, but I need help improving my runtime. I know it's a bit messy. What improvements can I make? ...
-1
votes
0answers
30 views

Map generator for zelda clone

I'm starting on a zelda clone in pygame for coding practice, and was thinking of how to program the maps. The idea, similar to the early Legend of Zelda games, is that a square, tile-based map will be ...
1
vote
1answer
12 views

Using a dictionary template for consistent response structure from an API

I am making a simple API for news items using Python and the Bottle framework. I return a Python dictionary from my endpoints as Bottle converts this to JSON automatically in the response to the ...
2
votes
0answers
54 views

Chat using async Python and sockets

I am trying out websockets using the python async framework aiohttp. Basically I have created a game which will include multiple ...
1
vote
2answers
59 views

Shorten runtime of this Python program

This is an answer to this question on Code-Golf.SE (but obviously not golfed). How can I shorten the runtime of my program? It is taking far too long to run some of the test cases. Can I utilise ...
1
vote
1answer
34 views

Point where maximum intervals overlap

I am solving the "Point where max intervals overlap" problem on geeks for geeks, https://www.geeksforgeeks.org/find-the-point-where-maximum-intervals-overlap/. Following the solution in the article, I ...
2
votes
1answer
29 views

Putting the results of a first JSON file of to subparts of a second one when key matches

I have a geojson file with results for each province and one that gives other results for each constituency (an administrative part of the province). I would like to make a third one that puts the ...
-1
votes
0answers
30 views

Function to extract Top 10 in State

Was told to post this over here.. In the code below Ive been extracting the top ten non-profits based on Income from each state, putting them into a variable and then merging everything into a new ...
3
votes
0answers
36 views

Binary Search Tree (BST) Implementation

This is the first Time implementing a Binary Search Tree, based on how it works from the visualgo website. I made this algorithm purely based on what I saw, and the remove method was quite challenging....
5
votes
1answer
52 views

CLI Tic-Tac-Toe in python

Is there any way I could make my Tic-Tac-Toe board more aesthetically pleasing? Is there anything else I can improve besides the look of the board? ...
2
votes
3answers
261 views

Is there a better way to retrieve variables from class method

Currently my code works but I wanted to know if I'm going about this the right way. I want to be able to individually call variables from method 'data_by_name' in 'otherfile.py' . At the moment I ...
4
votes
2answers
90 views

Bet settling function in Python

I'm trying to write a function that takes a sports bet and returns its Net result. If you are not familiar with betting, an exhaustive test suite should help with understanding what the program is ...
2
votes
1answer
33 views

Better way to extract html table to dictionary using beautifulsoup in python

I am scrapping html pages. Part of the page has a table which has acts and sections of those acts mentioned in table format. For some other project I need to convert them to Dictionary. The key values ...
3
votes
1answer
53 views

Web Scraping Dynamically Generated Content Python

This is a small web scraping project I made in 2 hours that targets the website remote.co . I am looking forward for improvements in my code. I know about the inconsistency with the WebDriverWait and ...
1
vote
1answer
38 views

Start task as soon as multiple tasks are successful

I write an hobbyist application that collects soccer-data from different sources around the www and aggregates it for a graphical representation and sends it out as a tweet. Now I want to fully ...
3
votes
2answers
85 views

Merging folder paths into a tree structure

I have some paths in a list. Here is an example: ...
3
votes
0answers
40 views

Yolov3 Real Time Object Detection in tensorflow 2.2

Note As there are a lot of related modules in the project, I recently posted several similar posts(because all content cannot fit due to character limit) and someone indicated that this might be ...
1
vote
1answer
25 views

Stack Implementation Using Linked Lists

I have tried Implementing Stacks Using Linked Lists, and would like some tips and tricks regarding optimizations or ways to simplify/compact processes. It has 3 functions, Push, Pop, and Peek (For ...
1
vote
1answer
42 views

Functional Python Script to write a large amount of CSVs to database

I just finished up this script that crawls hundreds of local git repos for csv files and then stores them into a database. I've tried to follow a "functional" paradigm for this script but am kind of ...
1
vote
0answers
25 views

Efficiently update matrix calculations in Python

I'm trying to create functions in Python that would update calculations for a matrix only for new entries. These functions are created within a Design class, where users would submit a design into an ...