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
0
votes
0answers
7 views

2048 in Matplotlib

2048 in Matplotlib How to improve the code? I did an OOP to make 2048 using Matplotlib visualization. The color dictionary is for setting different colors to each ...
6
votes
2answers
365 views

Coin Flip Streak from Automate the Boring Stuff with Python

I apologize beforehand if the question has been repeated so many times. This is a practice task from Automate the Boring Stuff with Python. In brief, the task entails writing a code that carries out ...
0
votes
1answer
29 views

Is the math on my Coin Flip Streaks script correct?

I am attempting to complete the coin flip streaks problem from automate the boring stuff with python. My code works fine but my only concern is the phrasing of the task. Does the question want us to ...
4
votes
0answers
46 views

Post json using http and verify whether all actions completed successfully or not

I am working on a project where I need to work with http apis and call them using Python language. Below is what I need to do: Take few input parameters like - <...
3
votes
0answers
17 views

how to merge two lists based on common key value in python

I am trying to get some data from remote server based on fields provided in HTTP/POST request. There are some 1500 fields, however at any given time I can query only 30 fields. So I am breaking the ...
5
votes
1answer
112 views

Return correct path if windows or linux

I have been trying to code something simple where I call a class with different functions to different paths, if I call etc: ...
1
vote
0answers
30 views

Subprocess opening files

I am using 2 functions written in Python to convert a DLG file to PDB energies: ...
1
vote
1answer
23 views

Fill a pandas dataframe (of predetermined size) with results from a similar dataframe (of size less than or equivalent to the original)

I'd like some feedback/suggestions on how to improve the following. Specifically I want to know if what I'm doing is reliable and fast, or if there is a better way to accomplish this. The problem: I ...
1
vote
0answers
21 views

Python WordCloud GUI

Module: https://amueller.github.io/word_cloud/ I really enjoyed the python WordCloud module, so I wanted to give it a GUI so I could share it with family and friends. I also wanted a platform where ...
2
votes
0answers
10 views

Flask Database Design with ORM

I am designing a Stock Currency application and for that, I created a database. I searched for my question here first but the answerer told me to ask the same question here. ...
7
votes
1answer
217 views

Blackjack / 21 in Python3

I have created a blackjack game in Python3 but I am worried that it is not very efficient and also there are some problems with it. Problem 1) The player almost always wins unless he goes bust as the ...
3
votes
0answers
12 views

python collectd prometheus scraper

I've been tinkering with python for quite a while but have never taken on a challenge like this - I'm trying to write a collectd plugin to scrape metrics from prometheus endpoints. My goals are to ...
2
votes
0answers
94 views

Implement vectorization instead of nested loops on dataframe

I have a dataset ('sample_data.csv') of the form below: ...
5
votes
0answers
60 views

Simple chat server in Python

I'm new to both Python and socket programming and figured setting up a simple chat server would be good practice. In addition to general critiques of the code, I have specific questions: What are the ...
0
votes
1answer
30 views

How to get the indexes of smallest value per row in a DF, as column index and not column name? [closed]

I'd like, from a DataFrame, to retrieve a Series which contains the index of the minimal value per row (so ...
8
votes
1answer
72 views

Dealing cards for a game - my first Python project

I am new to Python but I aspire to become a 'proper' Python coder, (maybe even one day help the noobs on CodeReview :) Therefore I want to get into good habits early, and would really appreciate some ...
5
votes
1answer
45 views

Calculator that finds the area under a curve

The program is meant to collect from the user: The function under which to calculate the area The left and right boundaries of the region The amount and position of rectangles to use to approximate ...
2
votes
1answer
44 views

Managing a store in PostgreSQL

I have been trying to improve python combined with Postgres. At this moment im only sending two values to database which are etc: ...
4
votes
1answer
70 views

Tic Tac Toe game in Python - Beginner

I'm a beginner to python and as part of my course I'm instructed to create a simple tic tac toe game. I'd be very appreciative and interested of any insight, criticism, instructions, best practices or ...
2
votes
3answers
178 views

Iterative uniform recombination of integer lists in python with numba

I have a list of N integers and I iteratively take two integers at random, which are not at the same position in the list and uniformly recombine their binary ...
1
vote
4answers
90 views

Leetcode minimum path sum

Link here I'll include a solution in Python and C++ and you can review one. I'm mostly interested in reviewing the C++ code which is a thing I recently started learning; those who don't know C++ can ...
28
votes
5answers
6k views

A first “Hangman” game in Python

I am new to Python (it's my first language), been coding for a couple of weeks now. I have already made a couple of simple scripts to download and manipulate some financial data, but lately I thought ...
2
votes
1answer
38 views

Design pattern for creating similar but different classes

I have a main-class that takes a list of sources and returns two objects for each source; one with the required data and one analytics tool. The Analytics-class has ...
1
vote
0answers
21 views

Set operations on a tree / Hierarchical set class

Initially, I posted this question on StackOverflow. I wanted to know if there's an existing library that implements the concept I have in mind, which is the following. I want to define a hierarchy/...
1
vote
1answer
43 views

How to make selenium in python faster

I'm making a bot for PlayStation 5. And restock is coming soon so I want to make my bot faster. The approximate duration is 4.90 seconds. Is there any way to make this faster? I found that I should ...
0
votes
1answer
35 views

Matplot lib : scalling of the axes on bar plot [closed]

I am using following script to plot cluster populations using two lists contained x and y data ...
5
votes
1answer
98 views

A .py utility file for neural network learing rate policies

I've created a .py utility file, which specifies the learning rate policy for the neural network in PyTorch. The program in prior reads a ...
-2
votes
0answers
20 views

python: stacking images [closed]

My python script produces many images filles, that should be grouped togeter, according to the names of these filles. For example, within the same workdir there are n images, that can be grouped in ...
3
votes
1answer
1k views

Memory Game using Tkinter/Pygame

I'm very new to python and programming in general. For a school assignment, I made this Memory Game and would love to receive feedback from you guys. ...
2
votes
1answer
38 views

Google Foobar Level 1 - Minion Task Schedule

I recently just stumbled upon a post regarding Google Foobar Level 2 and decided to try it out myself but starting from Level 1. The description and code are shown below. Write a function called <...
9
votes
2answers
498 views

Microservice that fetches data from REST repository endpoints on Github

I have code in Python 3 where I fetch data from the GitHub API, and I want some advice on the architecture of this code. ...
3
votes
1answer
319 views

Timsort implementation in Python

I wanted to implement a Timsort in python. Here's what I've come up with: ...
5
votes
1answer
63 views

Kings Tour Python

This is a depth-first search Kings Tour. I call it like this because the king must pass by all coordinates only touching them once (like a knights tour). How could I improve? Thank You ...
-2
votes
0answers
18 views

How can I split a large list into multiple smaller list at certain indexes in Python? [closed]

Right now I have a list that looks like this... [1,2,3,4,5,6,13,14,15,21,22,23,24,25,26] I need to make smaller lists where each is split when there is a gap in ...
1
vote
1answer
62 views

Calling different class objects using python

Im trying to get more grip of Classes and also calling different classes to each other which will be more understandable when showing code before: Utils.py ...
-1
votes
0answers
31 views
12
votes
3answers
83 views

Suggestions on cleaning up Flask app

I've written a little bit of code to pull data out of my FitBit and store it in a GCP database for further analysis. The project is available here, but what I'd like to ask about specifically is the ...
-4
votes
0answers
27 views

What does numpy.float_(Y) do? [closed]

I am a newbee to python & numpy. A simplified version of python code I found is the following: import numpy as np def function(X): X=np.float_(X) return X ...
0
votes
2answers
73 views

Finding a common prefix

The problem I am trying to solve: Given a string, split the string into two substrings at every possible point. The rightmost substring is a suffix. The beginning of the string is the prefix. ...
5
votes
2answers
392 views

Higher or Lower guessing game

After an extended absence from coding, I decided I would make something to try and get back on my feet again. I ended up making a project that I have made several times before, a higher-lower guessing ...
0
votes
1answer
53 views

Leetcode spiral matrix

Link here I'll include a solution in Python and C++ and you can review one. I'm mostly interested in reviewing the C++ code which is a thing I recently started learning; those who don't know C++ can ...
2
votes
1answer
29 views

Bulk slack emoji downloader

NOTE The script relies on ruamel-yaml and requests packages available on pypi. I wrote a script which goes over the pack file details as specified by the emojipacks project, and downloads (and saves) ...
1
vote
1answer
41 views

Leetcode group anagrams

Link here I'll include a solution in Python and C++ and you can review one. I'm mostly interested in reviewing the C++ code which is a thing I recently started learning; those who don't know C++ can ...
3
votes
1answer
60 views

Function for accessing and searching dictionaries using /slashed/paths (like xpath)

So I have some data being returned to me in the form of a deeply nested Dict and I need to parse multiple values from it which may or may not be there. I saw this library (https://github.com/...
7
votes
2answers
869 views

Fibonacci sequence output

Here's the code I'm having trouble shortening. I am currently a beginner in Python 3.x. ...
-2
votes
0answers
19 views

Gets data from api, cleans, and stores in db - Is my folder/code structure good/pythonic? [closed]

Background First attempt at a larger project (half year since starting to code), first time using classes too. I'm after feedback on my code structure, is there a 'better' way to structure my code, ...
5
votes
2answers
86 views

Mapping column names and values of a csv using another csv

I have two csv files, pricat.csv which contains objects I need to populate my DB with, and mapping.csv which specifies how the ...
4
votes
0answers
68 views

Optimizing recursive backtrack search algorithm in Skyscraper puzzle

I'm trying to solve a skyscraper puzzle for 6x6 boards using constraint programming and then backtracking. My solution works but is too slow, for certain cases, it takes up to 2 seconds and I was ...
2
votes
2answers
59 views

Lowest Common Ancestor in Binary Tree (Iterative)

In the below code I've implemented a method to find the lowest common ancestor of a binary tree. This is an iterative approach using this pseudocode. Please suggest any improvements that can be made. <...

1
2 3 4 5
261