Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008.

learn more… | top users | synonyms (1)

3
votes
0answers
8 views

Coin Estimator by Weight

i've created a mini project where the user will enter the total weight of the coins and the program will compute how many coins they have and how many wrappers they'll need. I initially found this ...
2
votes
2answers
67 views

Get height for tallest possible stack of boxes

This code is meant to compute the height for the tallest stack of boxes out of a given collection of boxes. A box has width, height, and depth dimensions. The height of a stack of boxes is the sum of ...
0
votes
0answers
31 views

Generate random URL and download HTML from website [on hold]

I'm very new to Python and I wrote the following program as my first program. My code works as intended but it's really really slow and sometimes it gets stuck for multiple minutes. I don't really ...
0
votes
0answers
29 views

Extracts features for 5 electrodes

This is part of my code that extracts features (PSD bands) for 5 electrodes. But I have other 14 electrodes from which I want to extract features too. The name of the 5 electrodes used here are C3, C4,...
4
votes
1answer
189 views

Removing duplicate files in a given directory

The following code is a python script that removes duplicate files in a given directory. At first I considered the most basic thing: relying on identical names, but you might have 2 different files ...
3
votes
0answers
18 views

Print Python docstrings when module is executed interactively

I have written a module, which should only be used by means of import, then call the functions as required. I do not want this module to do anything when ran interactively, other than printing out ...
3
votes
1answer
42 views

Unique nucleotide permutations, Python itertools product

I'm searching for all the unique possible permutations of nucleotide given a defined length. By unique, I mean the reverse complement would not be counted. ACGT For example, permutations of length ...
2
votes
1answer
31 views

Phonetic Alphabet Trainer

This is a little program I put together to help people learn the phonetic alphabet. Feel free to query the code. ...
6
votes
0answers
42 views

Downloading HTML from random websites

I've never written a single line of Python before this program was made and all my "knowledge" of the syntax is from Enki ( an app ). I just wanted to download the HTML code from random websites and ...
7
votes
2answers
606 views

To the right, to the left, now rotate

I was working on HackerRank: Circular Array Rotation which is about coming up with an efficient algorithm for array rotations in right-ward manner. John Watson performs an operation called a right ...
6
votes
2answers
66 views

Generating matrix/image kernel from List

I have another question from same program where is full code, but this question focus only single process/function of that program. My problem is performance when creating dynamic Image kernel from ...
3
votes
0answers
13 views

Python simulacrum of windows copy window

I wrote a program to copy files with an progress bar that looks similar to Windows built in function. The copy function is run in a separate thread and the tkinter GUI is run in the main thread. This ...
3
votes
2answers
25 views

Largest substring which starts and ends with some substring

This code is meant to find the length of the largest substring within a string that starts and ends with a given non-empty substring. Here are some examples: ...
1
vote
1answer
36 views

Finding all factors of n efficiently

This function generates all factors of an input n. It begins at the square root of n, and checks numbers down to zero. When a factor x is found, then another factor must be n divided by x. Also, if ...
3
votes
1answer
32 views

Get a path between graph nodes using breadth-first search

This code is meant to implement a Graph class which has a method that returns a path between 2 nodes using breadth-first search. I'm doing this to improve my style ...
13
votes
1answer
150 views
+100

Trie implementation in Python

I have created a trie in Python and am looking for feedback. Specifically, I am looking for feedback on: If my code is 'pythonic' If my logic is proper when inserting and retrieving from the trie I ...
9
votes
2answers
150 views

Decoding grayscale PNG and performing Prewitt operator for edge detection

I'm a hobbyist programmer. What I try to do here is to read 8-bit grayscale PNG file. Then unfilter it. (That caused a headache). And after that perform Prewitt operator for "edge detection". I know ...
4
votes
1answer
41 views

Decide if number is Armstrong number

I just recently started reading the python.org documents and it looked like a really interesting language. Now, since Visual Studio 2017 supports Python, I decided to finally actually start learning ...
3
votes
2answers
50 views

Get subsets of a set given as a list

This code is meant to create a list of subsets of a given set which is represented as a list. I'm doing this to improve my style and to improve my knowledge of fundamental algorithms/data structures ...
3
votes
0answers
59 views

Python AVL Tree

While learning python, I decided to implement some data structures, this time AVL tree. I think the logic is correct, is there a way to make it more clearer and any ideas to add more tests? ...
7
votes
2answers
77 views

Recursive higher-order function

I have implemented a through function for myself in a project. Since I am still quite new in python and want to learn it correctly, I would be happy about any ...
1
vote
2answers
48 views

Find median of list of integers

This code is meant to find the median of a list of integers. The list is assumed to be of odd length. This is based of this HackerRank question. I'm doing this to improve my style and to improve my ...
1
vote
1answer
28 views

Return a path between graph nodes using depth-first search redo

I previously attempted to implement a Graph class which has a method that returns a path between 2 nodes using depth-first search. This is my latest attempt at this ...
1
vote
1answer
28 views

Return path between graph nodes using depth-first search

This code is meant to implement a Graph class which has a method that returns a path between 2 nodes using depth-first search. I'm doing this to improve my style ...
1
vote
2answers
98 views

A simple pocket calculator

I was searching the internet for some Python exercises, and I've found a lab assignment from University of Toronto. Here's the major of it: Question 1. Welcome Message In the if ...
6
votes
2answers
278 views

Reduce as many adjacent chars as possible in string

This code is meant to reduce a given string as much as possible by deleting adjacent characters. Here are some examples: ...
4
votes
1answer
58 views

Text-based Adventure-Game Engine

I wanted to create some kind of generic text-based adventure-game engine to see if I could build an interesting puzzle out of it. The idea was to define a mini-language to be able to define the ...
1
vote
1answer
57 views

Random number guessing game in python

I just started learning Python this week and put this together for my first program (outside of a Hello World one). Does anyone have any feedback/suggestions for improvement for this? I've tried to ...
2
votes
0answers
28 views

File copy in Python for slow networks (version 2)

This is a follow up of a previous question I have written a file-copy routine, as I experienced unreliable results using standard Python when copying file over very slow networks. The requirements ...
0
votes
0answers
26 views

Return path between graph nodes using breadth-first search

This code is meant to implement a Graph class which has a method that returns a path between 2 nodes using breadth-first search. I'm doing this to improve my style ...
-5
votes
0answers
20 views

Error while Saving pandas dataframe to msql database [closed]

I have a table in pandas dataframe df. i want to write this to database. so i am using df.to_sql, but getting error. i am using MySQLdb. ...
2
votes
0answers
41 views

Computing the weighted centroid dependent on previous row/column

I am working on a project for a Raspberry Pi that requires some image processing. The aim is to find a white line on a black background by finding the weighted mean in each row/column. However to ...
3
votes
1answer
35 views

Hash table using linear probing

This code is meant to implement a hash table class which uses linear probing. I'm doing this to improve my style and to improve my knowledge of fundamental algorithms/data structures for an upcoming ...
1
vote
1answer
41 views

Tokenize a mathematical statement string

The function tokenize generates tokens from a mathematical string. It can chain characters together to form longer tokens. This can be used to build a parse tree,...
3
votes
1answer
48 views

Selecting specific lines from a file and focusing on them only?

So I have a file containing a huge list of sentences, some containing keywords, and some not, so in order to specifically focus on the ones with keywords, I used this method. It works, but is there ...
3
votes
2answers
74 views

File copy in Python for slow networks

Please note: I have a follow up question with updated code, here. I have written a file-copy routine, as I experienced unreliable results using standard Python when copying file over very slow ...
0
votes
1answer
45 views

Quick sort a list of integers in place

This code is meant to sort a list of integers in place using quick sort. I'm doing this to improve my style and to improve my knowledge of fundamental algorithms/data structures for an upcoming ...
0
votes
0answers
6 views
4
votes
1answer
98 views

Efficiently creating a list of formatted hex values

My background is in C, and I'm finally learning this new-fangled "Python" that all the cool kids are talking about. I want to create a list of formatted hexadecimal values like so: ...
4
votes
4answers
150 views

Basic spellchecker with File I/O

This is a basic spell checking program that I wrote earlier today. It accomplishes the tasks that I had in mind, but was curious about improving my coding style and improving efficiency of my program. ...
3
votes
2answers
55 views

Python Knapsack greedy

Given a dictionary of cows and their weight: ...
0
votes
0answers
56 views

Cosine similarity computation

I have a matrix of ~4.5 million vector [4.5mil, 300] and I want to calculate the distance between a vector of length 300 against all the entries in the matrix. I got some great performance time ...
3
votes
2answers
61 views

Equivalents permutations function

My function is supposed to essentially give the cartesian product of all the letters in a string with the caveat that you have to give the permutations of every equivalent of each character in a ...
3
votes
1answer
76 views

Python script which translates a DNA sequence

For my Biology class, I made a Python script which takes a DNA sequence as input, translates it into an mRNA sequence, and then again into a tRNA sequence. It then matches each mRNA codon with an ...
6
votes
2answers
290 views

Function to find all occurrences of substring

This function returns a list of all the beginning indices of a substring in a string. After finding the index of a substring, the search for the next one begins just after this index. ...
-1
votes
2answers
93 views

Questionnaire for troubleshooting a phone [closed]

Is there any way I can make this code more efficient/ more compact? It is a troubleshooting system for a phone that asks for the users input; and gives a solution based on keywords. The solutions are ...
6
votes
1answer
152 views

Word jumble game

I took my basic Word jumble game and added some additional features to learn new stuff. My plan was not to have any pre-defined words coded in my python script but rather different group of words in a ...
3
votes
3answers
252 views

Recursively patching the properties of an ORM model and related models

The following excerpt is part of a method for recursively patching the properties of an ORM model and related models using a dictionary: ...
2
votes
2answers
85 views

Adjusting all depth data in a file by some elevation

The code adds up numbers from two different text files. It opens an input file 'DEPTH.dat' and reads the numbers after some headers as follows: ...