Tagged Questions
Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
0
votes
0answers
6 views
Checking the sum of pairs to match a target value
I'm new to Python and curious what looks good and what doesn't. The function I have defined looks for pairs in a list of integers and tells the user whether or not any possible pair equals the target ...
0
votes
0answers
12 views
Unfair die game
For this task, you're going to play a dice game, but first you must
prepare for an overwhelming victory. The game itself is very simple.
Both players roll a single die and whoever rolls highest ...
2
votes
1answer
21 views
Crank-Nicolson. Advection - Diffusion. Perfomance
I am writing an advection-diffusion solver in Python. I am quite experienced in MATLAB and, therefore, the code implementation looks very close to possible implementation in MATLAB. I implemented the ...
2
votes
3answers
36 views
Python Battleship Game
I have a 2-player game of Battleship written in Python, but I've reused a lot of code for the second player's decisions (particularly in the play_game function). I'...
3
votes
4answers
272 views
Find element that has been removed from a shuffled array
For a function to determine which element has been removed from a shuffled array, I came up with:
...
3
votes
2answers
60 views
Prime number generator in Python
I have made a Python program that can perform some prime number functions. For example, it can produce an endless output of sequential primes. I am looking for ways to make it faster and cleaner. When ...
3
votes
1answer
23 views
Noughts and crosses command line game in Python 3.5
Based on this Code Review answer, I have created a noughts and crosses game in Python, which asks for an index (1 to 9) and updates the grid, and displays it on the screen. I have done some very ...
-3
votes
0answers
29 views
Thread-safe RLockedList [on hold]
Is this list thread-safe? I am aware of the GIL, but Jython for example allows for true threading - would this still be safe in an environment with multiple kernel threads?
...
-3
votes
0answers
31 views
Redesign to change class por functions
I would like to know if is possible to redesign the code above to make it functional:
lazyproperty.py
...
4
votes
2answers
38 views
Temporal kernel filtering on video frames coming in a loop
I have a video which I read in a loop frame by frame. For every frame, I want to do temporal kernel filtering, the coefficients of which come from the input variable model (a dictionary). The temporal ...
5
votes
1answer
68 views
Music player written in Python using PyQt
Some days ago, in the middle of a flight, in one hour or so, I've written this basic music player using Python3 and PyQt4.
I needed some easy to use music player, so I decided to write this piece of ...
5
votes
2answers
70 views
Minimal spreadsheet program
I wrote a very minimal spreadsheet program in Python with tkinter.
Here I present the help text:
You can use this program to calculate neatly in table format.
...
5
votes
2answers
58 views
Parsing the lsblk output
I am a Python beginner learning Python 3. I have written two small functions that parse the lsblk output and return Linux physical and logical disks. Here is the first function:
...
2
votes
1answer
21 views
Arcpy script to check for TIFF files and add them to different lists
My script goes through sub folders in my main directory and based on a wildcard checks if a tiff file exists or not, if it exists then the file path is appended to the corresponding list. For example, ...
-2
votes
0answers
25 views
New coder having troubles with loops, [on hold]
New to python and was my first try creating a loop, and after endless hours of trying to figure out what was wrong, I'm stumped. Here's the code:
...
3
votes
3answers
197 views
Transforming tuple with (int month, int year) in string “mm/yyyy”
I would like to improve the following code:
...
5
votes
2answers
339 views
Determining if a relation is reflexive
A binary relation \$R\$ on a set \$A\$ is called reflexive if and only if \$R(a, a)\$ for every element \$a \in A\$.
I want to know if there can be any improvements made on the function below to ...
1
vote
2answers
72 views
Refactoring code to avoid breaking line because of 80 characters rule
Currently I'm trying to redo this code to avoid the breaking line because of the 80 characters rule:
...
3
votes
0answers
35 views
Counting squares in a grid that is subdivided by line segments
Problem:
Given a picture of square with a bunch of horizontal and vertical lines in it (lines are not necessarily spanning the full square length, in other words think of a fine grid with many ...
4
votes
2answers
64 views
Password generator in Django
I am a system admin, not a developer, so this might be pretty horrible code. This is a password generator. The point of the attempt was to become more familiar with Django at a lower level. I current ...
4
votes
0answers
45 views
Passing a custom parameter through a logger
I have a custom logger which logs all messages at WARNING level and above to a Slack channel. Certain error messages occur so frequently that they make it hard to ...
3
votes
2answers
187 views
1
vote
1answer
56 views
Phone troubleshooting questionnaire with Tk GUI [on hold]
I have been tasked to create a GUI that asks the user questions about a mobile device.the GUI I have created asks the user a sequence of questions to try and come to a solution.However, I feel that my ...
2
votes
0answers
98 views
Calculate stock portfolio profit based on CSV data
import time
import csv
import argparse
from nsetools import Nse
from colorama import Fore
nse = Nse()
t = time.time()
CSV file contains the following data, I ...
-3
votes
0answers
22 views
Making a scoring/ranking list in Python: changing the score of a certain participant [closed]
I'm working on a assignment which is way above my head. I've tried for days on end figuring out how to do this, but I just can't get it right...
I have to make a ranking list in which I can enter a ...
3
votes
2answers
82 views
Python Day Finder
I have made a Python program to find the day of the week of an inputted date. I did not want to use the time or datetime module, ...
3
votes
1answer
43 views
Python configuration module for a web framework
I'm currently writing a web framework and I wanted to add a configuration module for reading environment variables and a configuration toml file.
Here is the code. The comment in the ...
4
votes
1answer
60 views
Print fragment of multiplication table
I am learning Python online on Stepik platform, and unfortunately I don't have any opportunity to get reviews from the tutor. The platform only checks the correctness of the answer that my program ...
5
votes
2answers
246 views
Print some elements from input
I am studying Python, so it is very easy task. I want to get best and most elegant way to solve each simple task.
The task is:
Write a program that reads the integers from the console one number ...
-6
votes
0answers
26 views
Python Selecting from list of lists by minimum value in given position [closed]
I have produced a list of lists in Python of the form e.g.
track_list = [[3,1],[3,2],[3,3],[5,4],[5,8],[6,6],[8,1],[8,90]]
I would like to consider each given value in the first position and then ...
5
votes
1answer
86 views
Find equal pairs
Problem
Given an array A of unique integers, find the index of values that
satisfy A + B =C + D, where A,B,C & D are integers values in the
array. Find all combinations of quadruples.
I ...
1
vote
2answers
42 views
5
votes
1answer
50 views
Add elements to a textfile using a dictionary
Is there a shorter way to write this code or parts of it and where can i inculde some try and excepts for validation
...
3
votes
0answers
27 views
Constructing queries with SQLAlchemy based on search parameters
I have an app where the user can search for items in my database by entering a set of information, then the server receives it and for each option it queries the database, and stores the result in a ...
0
votes
2answers
86 views
LSH hashcode generator function
For building an LSH based system in Python, I need to have a very fast calculation of the hashcode.
I won't need to explain here the LSH algorithm itself, but I need help in improving performance of ...
0
votes
0answers
39 views
Learn python threading by creating un-safe code - but it still works [closed]
G'day, my first post so please be gentle. I'm not sure if this is a valid question or how much detail is required.
I was trying to write some multithread python but some of the information I found ...
3
votes
3answers
67 views
Continuous sequence against target number
Post problem and my code written in Python 2.7. Any advice for code bugs, performance in terms of algorithm time complexity and code style are appreciated. I did PEB8 self-check in PyCharm.
BTW, a ...
1
vote
0answers
10 views
PySide Label Subclass Widget
I am using PySide and the following widget sublassed from QLabel to display either the current day or time in my application:
...
5
votes
5answers
462 views
Circular Array Rotation
My code works fine, but it's takes too much time, say around 65 seconds, for large input data. If there are 50,000 numbers in the list \$a\$ and we have to rotate the numbers 45,000 times then it ...
0
votes
0answers
57 views
Google Foobar prepare_the_bunnies_escape [closed]
I am on the first challenge of level 3 on Google's Foobar challenges. When I run the code with test cases on my own computer, they work fine, but when I verify it on the Foobar compiler, it says two ...
3
votes
0answers
34 views
Tarjan's strongly connected component finding algorithm
Here is my code for Tarjan's strongly connected component algorithm. Please point out any bugs, performance/space (algorithm time/space complexity) optimization or code style issues.
...
-3
votes
0answers
28 views
Lemmatization! how can I lemmatize a text in python [closed]
I want to lemmatize words like...word that ends with s like comes-come, but this way other words that normally ends with s get lemmatized business- busines, more over words ending like es, ed, ing,...
1
vote
0answers
30 views
Joystick to mouse/keyboard mapping program
I've been working on a project to map a joystick (in my case Logitech Extreme 3D) to mouse and keyboard so I can use it for web games that don't support gamesticks. My design goals are:
Flexibility - ...
3
votes
1answer
47 views
Multivariable Gradient Descent in Numpy
Just recently started learning ML, first I've gone through the notes of Ng's Coursera stuff. While I have nothing against Octave, I'm trying to solve exercises in Python. It's my beginning with that ...
0
votes
2answers
31 views
Count the number of vowelgroups in a string
I've written a function that can count the vowel groups in a string.
...
3
votes
1answer
68 views
Square free number
Square free no: It is an integer which is divisible by no other
perfect square than 1. For example, 10 is square-free but 18 is not,
as 18 is divisible by 9 = 3^2.
The smallest positive ...
2
votes
2answers
81 views
Random password cracker using brute force
I created a fun password cracker using literal brute force, searching each character to see if it matches an ASCII character ...
0
votes
0answers
21 views
3
votes
1answer
33 views
One-time pad encryption using letter shifting
This program asks the user to input a List of words. It then returns a list of encrypted words, and a second list which specifies the numerical shifts used to encrypt those words. The idea was ...
-1
votes
0answers
13 views
Finding Array is subset of another [closed]
I have a question. Is there a way to check if an array is a subset (elegant way without use of multiple for loops) of another.
For example, I have two 2048x2048 arrays. I used the np.where() function ...