Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [python]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

0
votes
0answers
3 views

I'm looking for suggestions to start an assignment I'm working on for capturing data on certain websites

overall objective: capture data for all providers some unknown set of IDs that designate the prviders. If you request a page with a valid ID you get a page with provider info If you request a page ...
2
votes
0answers
30 views

Read list of dictionaries with nested dictionaries

I have a file as content a list of dictionaries (Around 75000). For instance, this is an example of first line I got when reading the file (value for v): ...
-1
votes
0answers
9 views

Using google calendar api to loop over events(login error?) [on hold]

For some reason i cant use this code to clear a secondary calendar since the .clear() function only works for a primary calendar. this is my code: ...
5
votes
2answers
32 views

Creating a description of an item from an inventory

I'm really new to Python (like only a month of study) and I was testing out dictionaries, so I tried to make an 'inventory' where you can pick an item from your inventory and examine it. But I can ...
2
votes
0answers
30 views

Orthogonal sampling

I have been staring at what I have produced for almost 5 hours and I still cannot see how and where to improve my implementation. I am implementing an Orthogonal sampling method according to the ...
1
vote
0answers
23 views

Renting vs. owning comparison calculation

I have working code that compares rental prices and owning costs, given some parameters. It works, but it surely does not look good. I hadn't worked with time-series before and I wonder how I could ...
1
vote
3answers
142 views

Password generator in Python 3.7

I am learning how to code in Python by myself and have never coded before, I just want to know if there is any way I can upgrade my PasswordGenerator. ...
0
votes
0answers
26 views

Using nested multiprocessing pools in python

I'm processing image files, which are represented as 2d numpy arrays in python, and I need to iterate over the row of each array to apply a function. This is a ...
1
vote
1answer
28 views

Class with predefined ellipsoids

I am creating an Ellipsoid class and I then want to instantiate a few constants (pre-defined Ellipsoids). Below is my current implementation. I am not really ...
-5
votes
0answers
17 views

algorith program [on hold]

It takes 'x' minutes to drive to the mall and park the vehicle, and 'y' minutes to get the clothes dry cleaned, ‘z' minutes for lunch, 'a' minutes to get dog food, 'b' minutes to get money at the bank ...
3
votes
0answers
32 views

Python script for OpenStack health check

First time moving from Bash to Python for scripting and looking for feedback/improvements. I've spent the weekend learning about OOP, and am aware that not fully utilizing it in this script — so any ...
2
votes
1answer
37 views

Simple one time pad cipher

I had this idea not to long ago on creating a secure chat for people who need to be not meddled with when talking (like whistleblowers, hackers, etc) talking to one of my friends about it he said I ...
-1
votes
0answers
16 views

Classification algorithm [on hold]

I just wrote a classification algorithm and would like to get some feedback if possible. Is this the right way to implement this code or it should be done any other way? ...
-1
votes
0answers
10 views

Complexity analysis for while loop + list.insert()

I have the following code for merging two sorted arrays in-place: ...
3
votes
2answers
397 views

Insert a number in a sorted list and return the list with the number at the correct index

I feel like the title is a bit wordy. What I have defined here is a function that takes two parameters: a list that contains valued sorted from smallest to biggest a number to insert at the right ...
2
votes
0answers
45 views

Custom autoclick Python script

I'm a newbie Python programmer and I just made my first script which allows autoclicking into various positions of the screen (3 for now) an X number of times with an Y interval. I'd like to know ...
0
votes
1answer
54 views

Taking text from a file and formatting it

My code takes numbers from a large text file, then splits it to organise the spacing and to place it into a 2-dimensional array. The code is used to get data for a job scheduler that I'm building. <...
1
vote
1answer
30 views

Adding GUI to game of life hinders performance

I created a simple game of life and I used console prints to debug and visualize it at first. However, when I tried to introduce GUI (using Python tkinter), the ...
6
votes
1answer
58 views

Extracting an adjaceny matrix containing haversine distance from points on map

I am extracting 10 lat/long points from Google Maps and placing these into a text file. The program should be able to read in the text file, calculate the haversine distance between each point, and ...
-5
votes
0answers
27 views

REMOVE DUPLICATION [on hold]

I want to remove multiple hits in my fasta file. I did blast and obtain the same hit but having differnet start points. Can we write a code to give a window of +/- 50 to start point so that any point ...
3
votes
1answer
73 views

Pouring water between two jugs to get a certain amount in one of the jugs (2)

I have been practicing recursion lately and I came up with this code to solve the water jug problem, given two jugs of volume jug1 and ...
7
votes
0answers
56 views

Replace color in image measured by Euclidean distance

This script replaces the red hair in image to black color (replace one color to another) Three major parts in this script Not just replace color red to black, I hope the output image looks natural, ...
-3
votes
0answers
29 views

Remove lines from csv if duplicate value in column

i am trying to write csv parser so if i have the same name in the name column i will delete the second name's line. For example: ...
5
votes
3answers
200 views

Picking the smallest value in a list using recursion

This is the code I wrote in order to find the smallest value in a list using recursion.However I feel like there would be a better way to do this? ...
3
votes
3answers
166 views

Bank account balance, withdraw, deposit: compartmentalize without losing functionality

Is there a better way to write this while maintaining its current functionality? (checking balances, updating, subtracting, etc...) If so, where would I begin? I saw a code briefly in class that was ...
4
votes
2answers
110 views

Simple Python Pygame Game

I'm trying to make a simple game for a school project. Do you have any tips on how to simplify and beautify the code? GitHub ...
2
votes
2answers
58 views

Genetic Algorithm - heavy memory usage

I have implemented two pieces of code as part of an Evolutionary Algorithm study: Particle Swarm Optimisation (PSO) and Genetic Algorithm (GA). Both are designed to find an optimal solution to a ...
0
votes
0answers
18 views

Find and replace set of words over multiple files [on hold]

I have 10 different csv files wherein Market_Name column is common. There are four names which i want to replace with other names for all 10 files. I can do this with map function over single ...
0
votes
0answers
31 views

Quiz Game Menu Frame

I am working on a menu screen program that will allow users to select quizzes on different categories and sub-categories. I had started with pygame initially but decided to switch to tkinter because ...
-3
votes
0answers
13 views

Deep learning with python/keras : How to use a pre trained network after several user defined convolution layers? [on hold]

I'm working on a deep learning network, I use Python/keras to implement it. My goal is to count objects on pictures. I follow a similar approach than developped in this paper: https://www.mdpi.com/...
2
votes
1answer
57 views

Object-oriented student library 2

Follow up of Object-oriented student library Question: How do you refactor this code so that it is pythonic, follows OOP, reads better and is manageable? How can I write name functions and classes ...
-4
votes
0answers
32 views

Comparing the similarity of long lists of characters [closed]

I have a program that reads the raw data of a json file and compare data lists which have a lot of characters inside a list. The raw data lists are as follows: ...
9
votes
0answers
58 views

Paint program made in PyGame

I am making a paint program in Python using Pygame. Right now the program is very laggy, and I wanted to get my code reviewed incase the reason is in the way I have written the code. EDIT: I was ...
3
votes
1answer
53 views

Python webscrape Amazon Music, generate tracklist

So I've been working on a tracklist generator that scrapes from Amazon Music using a url using Python for albums with one artist. I've made uhhh this, I'm really new to this requests and ...
1
vote
2answers
67 views

Generating string expression from data for filter

I have a set of parameters, and I need to get the expression: So I got this parameters: ...
0
votes
0answers
55 views

Get directions for unit movement with conditions

I am developing a bot for Starcraft II. In my code for unit movement, I often find myself doing this: Calculate points around the current position of the unit Check if these points are valid and can ...
-3
votes
1answer
52 views

Reducing function calls with Map [closed]

Currently I am working on reducing function calls in my tool. My function is called add_field_and_calc ...
4
votes
1answer
55 views

Implementation of Singly Linked List

I'm a data scientist attempting to build stronger CS fundamentals, particularly in Data Structures & Algorithms. Below is my attempt at implementing a Singly Linked List. Looking for advice ...
-3
votes
0answers
23 views
3
votes
0answers
26 views

Auto classification of my bank transactions

This is my first Machine Learning algorithm using Python and SkLearn. The code works, which is pretty awesome. I'm getting about 65-70% of accuracy after training it with about 4k rows of data. ...
5
votes
1answer
54 views

Unit testing for Python function that checks whether a value is in a range

This is the first time I've ever tried to write unit tests before, so I wanted to post here to see if I'm doing it "right". I read a couple of articles on the subject, but I work alone so I want to ...
9
votes
1answer
235 views

Pretty printing of the numpy ndarrays

Following this idea for pretty printing of numpy ndarrays, I have developed a very primitive prototype: ...
-3
votes
0answers
34 views

Best practice - naming multiple variables returned from a function [closed]

I wrote a program which has a main() module. In that main module I call other functions, which return values. One function returns multiple values, as a tuple. I'm asking about best practices for ...
2
votes
1answer
26 views

Split CSV file into a text file per row, with whitespace normalization

I have a CSV file that I would like to split up by row, do some whitespace processing on the string data in each row of the document column, and then output the processed data into separate TXT files ...
0
votes
0answers
23 views

Hangman exercise from Althoff book [closed]

Here's my code. This is my very first exercise in python. I'd like to know how to make it look more professional. There is a solution in Althoff's book, but I wrote mine. ...
0
votes
2answers
39 views

Incrementing specified list values, with “catch-up” [closed]

I completed a coding challenge recently in which my function was to be given two parameters: N, the number of counters to be used (numbered 1 through N) - and A, an array of integers. Iterating ...
5
votes
1answer
73 views

process data with numpy seems rather slow than pure python?

In my opinion, Vectorization operation with numpy should be much faster than use for in pure python. I write two function to get and process data in a csv file, one in numpy and another in pure python,...
0
votes
0answers
59 views

Simple Python Neural Network [closed]

I'm currently implementing a simple neural network in python to better understand the logic of a neural network. With this implementation, I have good predictions, but searching solutions to improve ...
3
votes
2answers
54 views

Contest Solution: Remorseful Sam

The Problem Sam Morose served for many years as communications officer aboard the U.S.S. Dahdit, a U.S. Coast Guard frigate deployed in the South Pacific. Sam never quite got over the 1995 ...
1
vote
2answers
57 views

Tic Tac Toe Python

I wrote a simple tic tac toe game in python. (I wrote the game logic and implementation separately) (in this case, it's a command line interface, I may do a Tkinter version) Can you review the code ...