Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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

Assign values to answers from a questionnaire, input into a formula and calculate score

I was wondering if anyone could make any suggestions to how I could write the following more concisely and reduce the number of IF statements? If possible, I would also like to simultaneously assign ...
-2
votes
0answers
20 views

Neural network is not giving the expected output after training in Python [on hold]

My neural network is not giving the expected output after training in Python. Is there any error in the code? Is there any way to reduce the mean squared error (MSE)? I tried to train (Run the ...
3
votes
1answer
29 views

Update Google Sheet with Python

Below is a code to update a google sheet using the database values. The script is working fine but it is rather slow because of the sleep function which I have to put because of the "Quota exceeding ...
0
votes
0answers
27 views

N queens problem in python

I just tried to create a program for the N queens problem. ...
1
vote
1answer
37 views

Finding sequential recurrences in a list of numbers

I have a list like this: seq = [-2,3,-2,3,5,3,7,1,4,-5,1,4,-5,1,4,-5] I want to get all the sequential recurrences and where it happens, I feel the way I'm doing ...
3
votes
0answers
38 views

test REST API connection

I try to get my head around the unittest.mock module. Please tell me if this is the right way to test for the right response for the following method : ...
1
vote
2answers
41 views

Project Euler problem 50

I was just trying Project Euler problem 50. The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that ...
5
votes
3answers
283 views

Displaying a Sudoku Board

For my programming class, we have been tasked with creating a Sudoku solver; the first step of the project was to create a program which would display the game board based on input provided by the ...
-1
votes
1answer
54 views

Parallel Calling of Function for Non-linear Solving [on hold]

The end goal of my program is to use a non-linear solver to fit a set of parameters to my data set. I pull the data set from a database into a list sprays, then ...
2
votes
1answer
56 views

Scrape company data from Google search

I have written this code for crawling and scraping search results from Google. But it's super slow when I run it. What it does: read a pandas column, search values in Google and take the first result ...
1
vote
1answer
15 views

Django: App based at PolymorphicModel

I'm building a simple Django app for reviews of different objects (restaurants, car services, car wash etc). I started with the app, but soon I faced first problem. Every object has features (but ...
-2
votes
0answers
36 views

Python import order for only two packages [on hold]

Just out of curiosity, what's the best way to order only two import statements at the top of a file: import numpy as np from functools import reduce According to ...
2
votes
1answer
73 views

Tic-Tac-Toe with changeable board size (Part 2)

Part 1: Tic-Tac-Toe with changeable board size (Part 1) I just revisited all my previous questions and saw that I hadn't updated my Tic-Tac-Toe code. So, I improvised my code as per @Austin Hastings ...
-3
votes
0answers
26 views

Adding difficulty in math quiz Python [on hold]

This is for a python code that I'm trying to make. I'm a new python user and this is the first real code I've made but I can't find anywhere to as how to change the difficulty. This project is a math ...
3
votes
1answer
58 views

Linked List implementation in python 3.x

I took this as a challenge and implemented linked list data structure in python ...
4
votes
2answers
84 views

Run length encoder decoder

The code works not only as a normal run length encoder and decoder, but it also works for values like 3ABC (Prints ABCABCABC), ...
3
votes
2answers
57 views

Morse code encoder decoder

I created this morse code encoder and decoder. ...
4
votes
1answer
49 views

Scrabble Scorer in Python

I made this Scrabble with care since it will be mainly used by family that will not understand the error codes so that is why I catch basically every possible error, to make it user friendly. I have ...
4
votes
2answers
62 views

Python Friendly Form

The 'friendly form' of a number is written as a sum of reciprocals of distinct positive integers. eg. $$\frac{4}{5} = \frac{1}{2} + \frac{1}{4} +\frac{1}{20}$$ I have written a python program that ...
2
votes
1answer
38 views

Python - Automate code involving suffix [on hold]

I am trying to automate this portion of code in python (code shown for 2 polygons, I am trying to do the same for 10 000 polygons). Any ideas on how to implement this using ...
6
votes
1answer
38 views
+150

Jaipur board game learning agent

Link to my previous question. I've implemented the other features of the board game, and made a simple learning method that stores state values and makes optimal moves based on that. I've used some ...
4
votes
1answer
27 views

Save points cloud in PLOT3D format

I have the following function to save points cloud in PLOT3D format: ...
3
votes
1answer
31 views

Recursively listing the content of an FTP server

Today I found myself in need of programmatically getting a recursive list of the files on a remote FTP server to look for some data archives. Much to my surprise, I could not find this functionality ...
9
votes
3answers
996 views

Counting without zeroes

Below is a python script that generates the sequence ['a', 'b' .. 'z', 'aa', 'ab' .. 'az', 'ba', 'bb' .. 'zz', 'aaa', 'aab', ..] This is essentially counting in ...
5
votes
3answers
115 views

Python script - Parsing molecular formula

Is it possible to improve this code in terms of efficiency / line number ? (avoid nested code ...). It comes from a test I failed. I don't know how I could have done it better. ...
2
votes
1answer
55 views

Quadratic “Complete the Square” Solver in Python 3

I quickly wrote this program to transform quadratic expressions in general form into vertex form. \$ax^2 + bx + c \;=\; a(x-h)^2 + k,\quad\text{where}\quad h = -\frac{b}{2a} \quad\text{and}\quad k = ...
5
votes
1answer
72 views

Compiling Go with python

I've made a small script to compile Go code with Python. The result is not something I'm happy with, because: It seems overly complicated I'm worried the nested if-else with f string are unreadable ...
1
vote
1answer
47 views

How to check list of environment variable in python? [on hold]

I have requirement to check list of environment variable in Linux. Based on environment variable, exit code will be different. how to optimize the below code? ...
-3
votes
0answers
54 views

Writing better the if-else structure in Python [on hold]

After each query with the particular query (e.g., 1) value I would like to give the respective value (e.g., 2) to the new variable new_val. But it looks very ...
5
votes
1answer
57 views

Turtle controller with simple instruction set

I've made a controller for Python's Turtle. The controller essentially defines an 'instruction set' so that commands can be recorded in a text file and then executed sequentially by the turtle. It ...
5
votes
1answer
48 views

Remove words from an exclude list in each row of a pandas.Series

I am trying to remove all occurrences of the words I collect in the list exclude from every text note. This is my approach. ...
-2
votes
0answers
17 views

Best practice to insure the connection and response from external API results [closed]

I have this code in python (using django firmware) that connects to an external API and update some values in that service. Each ...
3
votes
2answers
92 views

Beginner Tic-Tac-Toe in Python

...
2
votes
2answers
44 views

Speed performance of picking unique value from binary matrix file

I wrote this code to read a square matrix saved as binary file, that it can be int, uint, float etc... to pick a value from the matrix at given row ...
3
votes
1answer
85 views

Login system created with Python

This is a program that I created using Python. Please help me optimize the code. ...
6
votes
2answers
72 views

Bubble Sort Implementation in Python 3

I have implemented a Bubble Sort. It works well. But if you think something needs to be improved, say it. This code was tested in Python 3.7.4. ...
4
votes
1answer
46 views

Python timing optimisation

I'm new in this community and with Python 3! I'm trying to optimize this exercise: We have n strings stored in a txt file. Inside the strings a secret word is ...
1
vote
1answer
34 views

Custom String Formatter

I've written my custom implementation of an f"" / .format(...). I started the project thinking it was going to be longer than ...
-3
votes
0answers
42 views

Longest Palindromic Substr [on hold]

I am looking for review on the algo, and want to know the runtime complexity. Variable naming is garbage, I know. This is a Python function to find the longest palindromic substring using a ...
8
votes
1answer
62 views

File(s) encrypter implementation in python

I'm looking for any feedback in order to improve code styling, performance etc. Also I want to make sure that the way I've implemented AES here is actually secure ...
16
votes
8answers
3k views
+100

Stack data structure in Python 3

I have implemented a stack in Python 3, and it works well. If anything needs to be improved, I would appreciate the criticism. ...
5
votes
2answers
218 views

Productivity/Timer app that uses twilio to send SMS-reminders

I wrote a timer app in python using both twilio and the timer module; sends an sms to my phone after a certain amount of time has passed. While it works without a doubt, I wanted to gather some ideas/...
1
vote
0answers
17 views

Blob data from Oracle to .zip file using python [closed]

I have been trying to get the blob data from oracle into a zip file using Python. I couldn't find the answer on any of the other links. Below is the code:- ...
5
votes
4answers
216 views
+50

Tic Tac Toe Game in Python 3

I made this as a personal challenge. It seems to work fine as I can't find any bugs and am happy with how it runs, but I am interested in what I should do to make the code more professional. Note: ...
4
votes
1answer
41 views

Algo for generating a fake, but feasable, dataset

So, I was working on a dashboard for a potential customer and I needed a fake dataset with employee information to demonstrate. Mainly, I needed to know when the employee arrived the company (first ...
5
votes
1answer
51 views

Average row id volume

After a test run with LoadRunner I wanted to know the average time for each transaction for each VU volume step, the LR let you create a graph for this but don't give you the point values... so it's ...
3
votes
1answer
59 views

unique username generator

I have written a class to generate a unique username from the full name. The full name is the name of a company usually containing 4 to 5 words. The username generated will be of format {preffix}{...
4
votes
1answer
99 views

Automate html file editing with python - Change the author

Hello I would like to use python to change the author of an html file, in order to do so I have written a few lines. First I have used the HTMLParser class from ...
3
votes
1answer
38 views

Plot timings for a range of inputs MkII

To celebrate questions getting more reputation points per upvote, I revisited my previous question, Plot timings for a range of inputs. Since the time of that original question (more than two years!),...