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
16 views

Logistic Regression using word2vec [on hold]

I am new to python and want to train a LogisticRegression classifier on the pretrained word embeddings, using word2vec model. I use the polarity dataset consisting of 1000 (900 for train_set and 100 ...
0
votes
0answers
16 views

Python Tkinter Based Calculator

I've recently finished building a calculator in python using tkinter, and would appreciate any and all feedback on it. Please ignore the use of the "eval" function, I know this is advised against ...
1
vote
0answers
24 views

Matching socks from a bag of socks

I was reading the book Algortihms to Live By and was inspired by it to take a shot at simulating How to pair socks from a pile? (sans the efficiently part at the moment). ...
3
votes
1answer
42 views

Statistics and calculations

I went through a series of lessons in data science using pandas and numpy. I have attempted to replicate some of the more common algorithms based on maths forumlas and psuedocode, except for the <...
1
vote
0answers
28 views

Python rsync to copy the logs from multiple remote servers

I have the below code which i'm working to copy(using rsync) the contents From remote host labserver01 and dumps those into the directory ...
3
votes
1answer
68 views

python hangman (another one)

I'm pretty new to python and have created a simple hangman. Since doing so I realise this appears to be a fairy common theme. It uses /usr/share/dict/words on the local system, resulting in some ...
-1
votes
0answers
30 views

Set speed limit on request python [on hold]

I'm trying to implement a very basic download speed limit for requests.get in python. My concept is putting a delay on every 1KB download related to current speed and a ratio. For example, if we want ...
1
vote
1answer
81 views

Caesar Cipher improvement

Currently, I have this and it's working for all cases: ...
0
votes
0answers
30 views

Authentication program using external text file [on hold]

Complete noob here. I'm a computer science student just starting out with coding in Python. As a task, I have to let two people enter their details and have them verified. I've written this code, and ...
0
votes
0answers
9 views

Pivot DataFrame with DateTimeIndex

I have some data, which I've faked using: ...
2
votes
0answers
57 views

Multiformat text parser in Python

I am working on a small textract-based Python CLI tool that aims to extract text from either a single or multiple files, writing the output in corresponding text files. The input files can be of any ...
5
votes
1answer
40 views

Search father (x) of the number D(x) and measure time and memory consumed

We define function D(x) as following: D(x) = x + sum of digits of x + sum of prime factors of x then call x the father of D(x) Write a program that gets input ...
0
votes
2answers
72 views

Battleships “AI” function

I would like some advice on how I could shorten my function from my battleships game (below). Essentially what it does is it checks if a coordinate is a hit and if it is, then if checks adjacent ...
3
votes
0answers
46 views

Arabic language lesson program Part 2

This is the second time I am asking for a review of this code (first time can be found here: Arabic language lesson program). The goal of the program hasn't changed - to house Arabic language lessons ...
2
votes
0answers
41 views

A step into the world of smart cards

Intro As some hobby thing, I'm trying to understand the basics of smart cards. How they work internally and what can be done with them. Therefore I made my very first smart card program, which will ...
2
votes
0answers
50 views

One-handed Solitaire Game Choice Generator

I want to test some different endgame scenarios for one-handed Solitaire where the removal of the cards if the suit or value match is optional. I've written a simple generator which yields at the ...
2
votes
1answer
28 views

Read gzipped JSON file from URL

I am requesting a JSON file that's gzipped. First, I download file: ...
5
votes
1answer
606 views

Find the minimum number of characters to add to make password strong

This is the criteria: Its length is at least 6. It contains at least one digit. It contains at least one lowercase English character. It contains at least one uppercase English character. It contains ...
0
votes
0answers
21 views

Python: Calling user-specified functions inside a separate function [on hold]

I have a situation whereby there are 2 types of statistical metrics (cohens kappa and correlation). Each of these has their own function, whereby the user can input two sets of data and it computes ...
4
votes
0answers
41 views

Python CSV to XML converter

I'm creating an application that reads in data from a CSV file and creates an XML file using LXML. The below code works as expected. However, before I develop it further I would like to refactor it ...
-1
votes
0answers
15 views

Multi-threading/Multiprocessing Improvements In Python Program [on hold]

I have a python program that behaves as follows: ...
2
votes
1answer
76 views

Find the kth-to-last element of a singly linked list

I wrote this code for finding the \$k\$th-to-last element in a singly linked list. ...
1
vote
1answer
51 views

Maximise XOR of two elements

I have a number x and I need to choose another number y from the given range [l, r] such ...
3
votes
1answer
51 views

Centered finite difference approximation for edge enhancement

I implemented a centered finite difference approximation for edge enhancement in images. The difference approximation has a step size h of the partial derivatives in the x- and y-directions of a 2D-...
-1
votes
1answer
54 views

Decoding a string encoded by Caesar Cipher and some delimiters [on hold]

I have the following code which I seek to optimize. The result of the bruteforce I already have but I'm just trying to learn some more python using the same example. The code in the data needs to be ...
4
votes
1answer
57 views

Text-based adventure and combat game

I'm new to coding and this is a text based adventure game with combat. Sleep and choice functions based on idea from https://codereview.stackexchange.com/a/52292/179642. Map idea from Codecademy ...
-4
votes
0answers
66 views

python file handling [closed]

The academic office at the Hogwarts School of Witchcraft and Wizardry has compiled data about students' grades. The data is provided as text from standard input in three parts: information about ...
0
votes
1answer
50 views

Parse JSON strings as tables using Python

Needed a simple CSV file that had headers and no nesting of data to consume in Tableau. The JSON file I was consuming had nested dictionaries and lists (which sometimes had in themselves nested lists/...
5
votes
1answer
61 views

Arabic language lesson program

The program I have been working on has been developed almost exclusively as "train-of-thought" style code. Things happen linearly (for the most part) thru the code. The goal of the program is to house ...
3
votes
1answer
35 views

Reads paragraphs of common artists separated by commas

I want to make this faster, I'm not a great coder and just want to learn. This program reads paragraphs of common artists separated by commas. The user inputs the name of a desired artist and the ...
0
votes
1answer
35 views

JSON backup to backend server if connection issues

I have a program that includes sending data to our backend servers upon completion. Due to the occasional connection issue at either side I have coded into the main script a JSON dump as a backup in ...
3
votes
1answer
47 views
4
votes
2answers
97 views

Longest word in dictionary that is a subsequence of a given string

I am trying out the following former Google interview question. The Challenge Given a string S and a set of words D, find the longest word in D that is a subsequence of S. Word W is a ...
7
votes
1answer
140 views

View, append, write, or delete a file

I am just wondering if I need to refactor this code into smaller functions, or if it is OK as it is. I know that code should be as clean as possible, but I don't see a need to declare a new function ...
0
votes
1answer
64 views

Binary Search Python

Tried to make a binary search algorithm, how did I do? ...
2
votes
2answers
81 views

Processing lines in an event log to trace the status of a job

We have an event file which I'm processing to get the status of a job (process), whereas a single job contains multiple fields which I want to segregate based on what I required, for example, "...
-1
votes
0answers
26 views

Is This a Correct way of writing a project in django? [closed]

https://github.com/kvhnbasca/s This is the project. I have made a small project on ATM. 1)user can log in with his username and password.(users present in database) 2)A homepage will appear with *...
0
votes
0answers
119 views

Filling values for nested dictionaries

I have a text file where any name followed with sequence word is considered a dictionary. The task is to go through the keys and values of a particular dictionary, which is already identified, and see ...
-1
votes
0answers
20 views

parse bracketed text to array subscript representation [closed]

input text: {{{1, 2}, {3, 4}}} output: [0][0][0] = 1.0 [0][0][1] = 2.0 [0][1][0] = 3.0 [0][1][1] = 4.0 input text: ((5, 6, 7), (8, 9)) [0][0] = 5.0 [0][1] = 6.0 [0][2] = 7.0 [1][0] = 8.0 [...
3
votes
1answer
19 views

Create histogram with greater than symbol in x axis in pyplot

I wanted to create a histogram from a list of positive integers. I want to bin it so that I show all single numbers, say K through N, with more than k elements in the data set, as well as the number ...
2
votes
0answers
39 views

Interview: Appointment reservations

I have received this question during an interview I did earlier, but I found that my solution might not be correct. And I would like to know whatever there is a better way to solve this. Question: ...
0
votes
0answers
13 views

Python : Threading Dotstar pixels and PWM [closed]

I'm quite new to Python and I'm trying to have a dotstar led cycle and a pwm cycle at the same time. As far as I've figured out it's best to do multithreading which I tried here but I cannot seem to ...
-2
votes
0answers
16 views

How to input a user input into a function parameter in python? [closed]

Im trying to find the greatest common divisor of two numbers the user chooses using euclideans algorithm. Here is my code: ...
2
votes
1answer
23 views

ProcessPoolExecutor KMZ file search

I've written a script to look for coordinates in KMZ files. I've tried to speed execution up using the ProcessPoolExecutor. I'm quite new to Python, so any recommendations are more than welcome. <...
2
votes
1answer
99 views

String search algorithm for finding if a long list of long strings string exists in a similarly sized haystack

My use case is that I have a list of emails and I need to find if the email is in the chain: ...
6
votes
0answers
54 views
+50

Systemd service configuration helper script

I've written a script that semi-automates the process of configuring/creating a new systemd service. The script is working perfectly well, however, I've had some trouble with the styling and ...
0
votes
0answers
31 views

Choosing between types of Function Transformers : Sklearn Pipelines [closed]

I've recently started looking into pipelines to clean up my code. I would like to know which one of the following is the "better" approach when using Pipelines with Function Transformers and the ...
2
votes
4answers
100 views

Simple port scanner in Python 3

I wrote a simple python port scanner today and I would like to get some advice on how to improve on the code in different ways. I am aware that I can implement threading to reduce runtime but I won't ...
4
votes
0answers
73 views

Python expression calculator [closed]

This is a calculator I created. It can take all basic operators, including brackets. I am a beginner with Python so I want to know what can I do better next time I write something similar. ...