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

A better way to calculate Profit-n-Loss

So the problem is as follows: given a list of prices, what is the max possible PnL? so to buy low sell high what is the max profit possible? right now my solution involves making a copy of the list, ...
  • 131
1vote
1answer
35views

Fastest way to find common keys between many dicts and merge these dicts

I have 1000 dictionaries (grid_1, grid_2.... grid_1000) stored as pickle objects and one ...
  • 162
0votes
1answer
59views

Progressively erase tail of a Python list

Hey I started programming in python few days ago and decided to write a programme without any tutorial. You give it a list and then my programme erases last item of list until there's only one item. I ...
3votes
1answer
45views

Number Guessing Game Version 1

I made a really basic number guessing game based off a list of recommended projects, and i want to see if it follows the normal coding conventions before I aim to improve it(with lives, or hints, ect)....
-2votes
0answers
10views

jv(Bessel function) not found in module [closed]

I am using ipython to run the following: In [48]: from pylab import *; from scipy.special import * In [49]: x=arange(0,10,.1) In [50]: y=jv(0,x) Unfortunately I ...
-6votes
0answers
30views

can someone look at my for loop psuedocode? [closed]

Can someone critique my pseudocode to python please. I'm especially confused where I left my comment. ...
  • 1
3votes
1answer
56views

Python Poker Hand Comparison Progam

I recently started learning Python and the first program I've made is a program to determine the best 5 card hand from seven total cards and then to be able to compare two different hands to determine ...
0votes
0answers
22views

Games inside of (bot?) in telegram

I made something like a bot that connects to random people in some anonymous chats (using telethon) and some random guys can play small games Made this in like 20-25 minutes or something Half a year ...
0votes
0answers
16views

Python selenium online Stanford-Binet Test solver

This is a Python program that solves a version of Stanford-Binet Test found at https://stanfordbinettest.com, basically it is a selenium bot that goes to the test url and submits what I have ...
8votes
1answer
74views

Scrape a URL for articles to save

Below is an exercise project I was doing on a certain educational site. It is supposed to parse a given (static address in this example) URL for html data, search articles of a given type there and ...
0votes
0answers
7views

OAuth2 provider framework - ORM model generation

I recently outsourced the generation of OAuth2 authentication servers and appropriate ORM models into a common framework library. It mainly uses peewee, flask and authlib. Its purpose is to generate ...
4votes
2answers
66views

Convert a status list to summary value

I have a pattern that I have been using for a few lookup functions that I feel could be done in a better or more pythonic way. I am looking for guidance on how the following function could be improved....
1vote
2answers
98views

Create an ASCII table from CSV

The following code convert csv to ascii table. ...
  • 417
2votes
1answer
33views

Julian Date Distance Calculator (First Project)

I have watched a few youtube videos, and I am trying to learn a little bit more by doing. I had a blast trying to figure this out. I know it has issues such as not being able to go below 2001 and ...
0votes
0answers
13views

Python Socket Class transfer functions for any networking related program

This code is meant to send an object (any object) over a connection to a recieving program. I want to make sure that i haven't made any red flags. It seems to work fine, i've sent tuples with data (...
1vote
0answers
28views

Pandas Numpy Nvector to generate a storm track algorithm

I made previous post here, relating to this topic. The class uses now uses some additional 3rd party libs nvector & pygc. ...
-4votes
0answers
73views

Python script to make a merge between two DF and send a request to an API [closed]

I have a python script to merge some dataframes using pandas. I would like to know if there is any way to make it more maintainable, e.g. to use it with different sort of CSV files in the future or to ...
4votes
1answer
58views

Greedy number partitioning algorithm

I have two functions in Python that do the same thing: they partition a set of items of different sizes into a given number of subsets ("bins"), using an algorithm called greedy number ...
5votes
1answer
91views

Plants vs. Zombies simulator

I am making a pvz simulator. We have a game board with 1 = peashooter and 2 = zombie: ...
0votes
0answers
34views

A Python program that scrapes questions from an online Stanford-Binet Test website

This is a simple Python program that scrapes questions from https://stanfordbinettest.com/, it has a version of Stanford-Binet IQ Test which randomly selects 100 questions from a pool of ...
3votes
2answers
54views

Rover movement Python

A Mars rover is directed to move within a square matrix. It accepts a sequence of commands to move in any of the four directions from each cell: [UP, DOWN, LEFT or RIGHT]. The rover starts from cell 0....
  • 179
1vote
1answer
35views

Multiple GeoJSON Feature Collections to a Pandas MultiIndex DataFrame

Edit: The end objective is to monitor the movement of severe weather, determine its vector and make a prediction. I'm working with a GeoJSON ...
6votes
4answers
1kviews

Python budget calculator

I have, after years of excuses, started programming. Well honestly, I was not able to find any one interested in helping me with my start-up idea. So I had no choice but to ask myself 'How hard can ...
4votes
3answers
159views

Wordle puzzle game

I am a beginner programmer with not much experience, the little I do have is with Python specifically. With all the fuss going around about the popular word game "Wordle" I wanted to ...
2votes
0answers
22views

Can I better architect this image detection bot?

I'm trying to learn python by building an image detection bot for a 2d game. The bot checks to see if it can find any one of a number of images within a cropped section of the game window. If it finds ...
  • 121
2votes
1answer
40views

building a shell command inside python function based on different conditions

I have written the below python function which is working fine but there are lot of code which looks redundant to me and hence i want to make it better by using best coding guidelines. Basically I am ...
4votes
1answer
55views

Matchsticks game in Python

I made the following game in Python applying object oriented programming and I would like to know if there is something to improve. PS: My native language is Spanish, if you see something wrong ...
5votes
1answer
351views

Laser physics simulation

This is for a computation for laser physics. The speed is quite slow, which seems to be delayed a lot by the three nested for loops with indices j,k, and l (with comments below). And the computation ...
-2votes
0answers
12views

How to filter by the field which is not stored in DB using Django ORM? [closed]

I have a code like this ...
  • 97
1vote
2answers
52views

Take every second row in CSV file, and put it next to the previous row

I have a csv file ...
0votes
0answers
27views

Zigzag indicator for stock prices

I have read on SO and replicated an indicator for stock prices that works as intended. It's called ZigZag and projects peaks and valleys on historical prices. I pass a pandas dataframe with OHLC ...
-3votes
0answers
19views

Kivy App updating SQLite DB from Windows but not updating when run from Android phone [closed]

I've created a Test App using the PyCharm editor and the Kivy Package, when I run it from the PyCharm editor on my Laptop it updates SQLite database successfully and creates new records like user name,...
  • 1
-2votes
0answers
23views

how to fix HTTP Error 413: Payload Too Large [closed]

I am trying to fetch data from Openfigi without API key, I have limitation. https://www.openfigi.com/api#rate-limit I need to know how can I make changes to my code below like how to add sleep ...
  • 9
4votes
1answer
49views

Online check with retry logic and anti-flapping

I've got a network device that doesn't hold its WiFi connection brilliantly and occasionally drops off the network completely. Although there are dedicated network monitoring tools out there, I ...
6votes
2answers
388views

Construct Pandas DataFrame whose (i,j)th entry is the probability that a person aged i+100 will still be alive after j years

The following function takes the probability of a person aged 100+i dying in the next year (conditional on them being alive at the start of the year) and returns the probability that they will be ...
5votes
1answer
460views

Writing a lazy-evaluation dataclass [closed]

I have a dataclass which is frequently used but is slow because as it processes multiple large datasets. I have tried to speed it up by making it lazily-evaluate, where the data is only read when ...
  • 69
2votes
1answer
47views

Hangman game in Python with OOP

I made the hangman game using OOP. It is the first "big" project I do using OOP. I would like to know if there is something to improve in the program I made. This is the code: ...
5votes
0answers
48views

Structuring of my tkinter music player program

This music player app hasn't really completed yet but it runs the basic functions of a music player, which include play/pause, volume adjustment, next/prev, shuffle and repeat functionalities. However,...
2votes
3answers
110views

Kattis Battle Simulation

I have a working program for a problem, but need to optimize it in a way where the processing time is less than 3 seconds. This is where I found the problem: https://open.kattis.com/problems/...
  • 21
3votes
1answer
45views

Resume Builder using Jinja Templates and HTML

I have attempted to hack together a CV/Resume builder and I would like a review. The aim is to output a styled PDF containing dynamic fields. I have taken a simple HTML file, an arguably bloated CSS ...
  • 103
0votes
1answer
74views

Loop through polyline vertices and update coordinate

I have a Python 2.7 script that loops through GIS polylines and updates a coordinate. The coordinate is called an "M" coordinate (aka a "Measure-value"). M coordinates are similar ...
1vote
1answer
103views

Minimum re-labeling to make an array as close as possible to another one

I have an array with integer labels in [0, n-1], say arr1=[1, 0, 3, 2] with n = 3. And then I have another array again with integer labels in [0, n-1], say arr2=[0, 0, 2, 3]. How can I find the ...
  • 13
4votes
1answer
50views

Logistics project that implements several shipping APIs

I have a Python logistic project that implements several shipping APIs using class inheritance. Each of those classes must do three things: Fire requests to each endpoint with the proper parameters ...
3votes
1answer
33views

Radio Number station code generator in python (or substitute characters with alternating words)

I'm rather fascinated by radio 'number stations', and in preparing for a D&D game, I wanted to use such a method to encrypt complex messages as seemingly random strings of words. I wanted to add ...
3votes
1answer
39views

How to fine tune the complex python function for creating merge command to run in bigquery

I created a python code to run the merge command in Google BigQuery, which is used to do UPDATE, INSERT, and DELETE in a single statement. I'd appreciate it if someone could assist me in fine-tuning ...
  • 33
5votes
1answer
57views

Command Line Parser for my VBA package manager written in Python

As the title suggests, I'm creating a package manager for VBA which is modelled loosely on conda/ poetry, allowing you to install VBA modules potentially into "environments", but certainly ...
  • 1,782
3votes
0answers
53views

Tic-Tac-Toe Backend for Commercial Use

I've been working on a tic-tac-toe backend for an interactive commercial-use display, and was wondering if I could get some feedback on it? ...
  • 131
-1votes
0answers
37views

GAN having Mode Collapse, producing similar images

I am testing a GAN that I would like to have generate character images. After a few thousand iterations the images produced by the GAN all start to look very similar which I believe is due to Mode ...
3votes
1answer
147views

Lingo (word-game) guessing strategy

My friend and I are kind of noobs in Python and are looking for ways to improve. We thought it would be cool if we could get some feedback on the following code. It is for a game named "Lingo&...
6votes
1answer
61views

Calculating quantiles of timeseries data and then create a "fanplot"

My code is working properly, but I am looking for better approach in the calculation of quantiles and the finding of the data in the dataframe. ...
  • 63

1
2 3 4 5
288