# python's questions - English 1answer

8.467 python questions.

### 5 Numbers of length N and value less than K

2 answers, 356 views python programming-challenge
I am solving interview question from here. Problem : Given a set of digits (A) in sorted order, find how many numbers of length B are possible whose value is less than number C. Constraints: 1 ...

### 2 Relative frequency of words in tree of documents

I have a tree structure where at every node there is a list of documents (document length can vary from 5 to 500), and each document contains a number of words. I want to calculate relative frequency ...

### -2 Python , Mapreduce [on hold]

0 answers, 16 views python python-3.x mapreduce
...

### 7 Check if a given number N is a power of k

6 answers, 1.941 views python mathematics
I am trying to solve a problem to check whether a given number N is a power of k. Example: Input 9, 3 > True // 3**2 = 9 Input 10, 2 > False Input 4096, 16 > True // 16**3 = 4096 I want to know ...

### 6 Maximum coverage of set with minimum overlap

0 answers, 21 views python algorithm numpy complexity
Suppose I have a collection of items, each of which can have up to N labels. I am trying to come with an efficient algorithm to obtain ...

### 3 Prime number checker in Python 3 - follow-up

1 answers, 1.007 views python performance python-3.x primes
I have updated my code from the last time it got reviewed. If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated! ...

### 5 Using rotation of proxies within a Python script

I've written a script in Python using rotation of proxies which is able to fetch different titles from a website traversing different pages. I've tried to write this scraper in such a way so that it ...

### 1 A simple Blackjack game implementation in Python

This program is an implementation of the Blackjack which is similar to what is played in the casinos. Here were the requirements: I needed to create a simple text-based BlackJack game The game needs ...

### 6 Python 3 text adventure game

0 answers, 31 views python python-3.x role-playing-game
After posting here before, reading that advice, and doing some research, I re-planned and started over. The first thing I did was to create a map so I could see what I had to code for. https://sta....

### 7 Time delay indication bar for a text game

1 answers, 185 views python python-3.x console animation
For a game I am writing in Python 3.6.5, I made a text-based animation to indicate the passage of time (when chopping a tree or mining a rock, etc). I did a lot of trial and error to get the output ...

### 10 Farthest point algorithm in Python

I am learning Python and I tried to do a program to find K points from a set of N points, farthest as much as possible (I'm not ...

### 5 Show weekly and daily variations in time-series data

1 answers, 327 views python python-3.x datetime pandas matplotlib
I've got some time-series data. I want to examine the weekly and daily variation of that data. For weekly data I can make a plot like this, with the days along the horizontal axis: For daily data I ...

### Reclassifying movies by theme

2 answers, 40 views python performance python-2.7 dictionary
Any efficient way to solve the following problem assuming data is large. I solved the problem but how can I improve the code, which will make it efficient. any suggestions? Data: ...

### 5 Conway's game of life in pygame

1 answers, 41 views python performance game-of-life pygame
I've made a game of life in pygame. I need it to get it to run as fast as possible. I've done everything I can think of. ...

### -4 Compare two values in two different lists [on hold]

1 answers, 39 views python
I have two lists: actual_result : ...

### 5 Genetic algorithm for Traveling Salesman

I have implemented a genetic algorithm in python 3 for a programming assignment, and I think all the logic is correct. A friend of mine has also implemented one which carries out similar logic, ...

### 1 Function to generate pyspark diff and return differences in line

0 answers, 22 views python python-3.x apache-spark hadoop
I have written a function that takes two pyspark dataframes and creates a diff in line. I am struggling to get it to scale with 100s of columns. I get around the for...

### 2 Django social network application - database schema

0 answers, 9 views python performance database django
I am writing a simple social media application in Django. I would like to know whether the following model structure is correct, or how can I improve the schema to get better performance. Do I need to ...

### -1 Project Euler Problem #12 - Highly divisible triangular number

1 answers, 199 views python programming-challenge
Project Euler Problem #12 The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would ...

### 4 Cleaning and extracting meaningful text from tweets

I have a dataset of around 200,000 tweets. I am running a classification task on them. Dataset has two columns - class label and the tweet text. In the preprocessing step I am passing the dataset ...

### 4 Python task scheduler

1 answers, 44 views python multithreading
Submit tasks to a scheduler, allowing them to be run at a future time. Tasks can be submitted in any order, and non-running tasks can be cancelled. I used a min-heap to prioritize the next task, and ...

### 5 Convert JSON from a webservice to text file

2 answers, 51 views python python-2.7 datetime json file
I get list JSON text from a webservice and list_of_columns is predefined, I need the output in that format. I am not sure about few things which are as follows I ...

### 7 Python AVL Tree

1 answers, 874 views python beginner algorithm python-3.x tree
I decided to implement some data structures- this time an AVL tree. I think the logic is correct. Is there a way to make it clearer and do you have any ideas about more tests to add? ...

### 1 Find minimum absolute difference between nodes in a Binary Search Tree

I'm new to Python and I'd like some feedback on my proposed solution to the following (interview) question. Given a binary search tree with non-negative values, find the minimum absolute ...

### Cleanest way to get list of Django objects that have same foreign key and display them in a view

0 answers, 8 views python django
I am a beginner in Django and would like some advice regarding best practices. I have the following model: ...

### -4 Telegram Moderation Bot [on hold]

0 answers, 12 views python beginner
I would like to learn how to create a bot to help me manage my multiple telegram pages. I am looking for the bot to answer frequently asked questions.

### -4 Please check my basic number guessing game please [on hold]

1 answers, 36 views python
This is more of a request than a question, but I hope you guys wouldn't mind checking my code. I've just started out learning Python and attempted a lil project in a simple number guessing game. I saw ...

### 4 Python 3 text-based RPG (to be upgraded to Pygame)

1 answers, 47 views python game role-playing-game
I've been working on a text-based RPG for a while now on-and-off. After a long hiatus, I've come back to the project. My goal as of right now is to port the game from it's current Print-output ...

### 5 Console Monopoly in Python

0 answers, 58 views python object-oriented game
I began to program the standard version of Monopoly so that it could be played only using the console. I did this to practice Object Oriented Programming and have little to no background experience ...

### 7 Python Automate the Boring Stuff Collatz exercise

4 answers, 889 views python python-3.x collatz-sequence
I'm looking for some feedback on my code for the collatz function exercise in the Python book Automate the Boring Stuff. It works, but doesn't feel very elegant to me. Is there a better way to ...

### 4 Zipfile password recovery program

3 answers, 422 views python performance beginner python-3.x
I would like to get a few tips on how to improve this program, which is supposed to help recovering lost passwords from .zip files. ...

### 6 Find maximum gap between elements of an array

2 answers, 429 views python array interview-questions
I am solving interview questions from here. Problem : Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i] <= A[j]. Example : A = [3 5 4 2] Output :...

### 10 Simple concurrency implemented in Python

Purpose of the question: learn more about ways to implement concurrency in Python / experimenting. Context: I want to count all of the words in all of the files that match a particular pattern. The ...

### 2 Tic Tac Toe / Noughts and Crosses - First Program

1 answers, 67 views python beginner python-3.x tic-tac-toe
This is my first program. Its a two player noughts and crosses game. I would really appreciate any comments on how to improve my code or make it more efficient. Many Thanks. It is written in Python 3....

### Finding time complexity of my solution to the 'longest palindrome' problem in Python

1 answers, 30 views python complexity palindrome
Here is a short version! ...

...

### 5 Java String iterations

3 answers, 283 views java python strings iteration
I am working with some Java code. Basically I have a wrapper class that holds a string and implements some of the many useful python string methods in Java. My goal here is to implement the Python ...

### 2 Program to automate skipping users on a chat website until the username meets certain conditions (v.2.0)

1 answers, 28 views python web-scraping selenium webdriver
This is a python program that automates skipping through users on a chat website called talkwithstrangers using the Selenium Webdriver and BeautifulSoup modules of Python. The first part uses ...

### 1 Aggregate conditional logic test results iterated over changing row selections

0 answers, 34 views python performance beginner numpy pandas
This for-loop is the biggest bottleneck in my project, and I'm curious whether there is an opportunity to speed it up by improving the grammar or by using a ...

### 4 Extension on Python Lambda capability

2 answers, 69 views python python-3.x lambda
I asked for assistance creating a Python Lambda function capable of assignments and multi-line lambdas in this post. Following @l0b0's suggestions, I realized that it was better constructed as a ...

### 9 Scala inspired classes in Python

4 answers, 3.403 views python scala
I have to define a lot of values for a Python library, each of which will represent a statistical distribution (like the Normal distribution or Uniform distribution). They will contain describing ...

### 6 Read quantization tables from JPEG files

1 answers, 255 views python image cryptography http steganography
I'm developing an application that will hide information inside the quantization tables of JPEG files. It's called DQTsteg, if you want to know more about what I'm attempting to do. Right now I'm ...

### 3 Checking surrounding pixels inefficiently in pygame

0 answers, 34 views python numpy pygame
This checks surrounding pixels to my object's pixel: ...

### 1 A translator class in Python v2

1 answers, 75 views python google-translate
Version 2 of A translator class in Python Changes: Style compliant to PEP8 Both orig_str and filename allowed to be any object ...

### 3 A translator class in Python

1 answers, 142 views python google-translate
This class can be used to access the Google Translate web interface and get translation result for large text (split up into sentences). The Signal class is copied ...

### -3 Get list of surrounding pixels of a pixel in pygame [on hold]

1 answers, 47 views python performance pygame
I am doing some pixel operations in Python, which obviously uses a lot of processing power and makes the program extremely slow. I have these nested loops: ...

### 2 Translating text using Google Translate mobile site

1 answers, 305 views python web-scraping google-translate
I have this code to translate text using the Google Translate mobile site. Currently, text size is limited by the request method. Everything else seems to works just fine. I am also about to post ...

### 5 Parallel quicksort algorithm taking way too long

Below is a Python implementation of the quicksort algorithm using parallelism. It takes about 1 second per every 10 items in the list, which is hilariously unacceptable. Why is it so slow? ...

### 3 Simple product inventory project [on hold]

2 answers, 53 views python beginner
The goal: Create an application which manages an inventory of products. Create a product class which has a price, id, and quantity on hand. Then create an inventory class which keeps track of ...

### 3 Python 2 Stack and LinkedList implementation

2 answers, 53 views python linked-list stack
I'm currently implementing data structures and algorithms I studed in my college course. This is my implementation of a singly linked list and a stack. I would appreciate some feedback in terms of the ...