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)

0
votes
1answer
11 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 ...
0
votes
0answers
9 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
23 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
0answers
40 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 ...
5
votes
2answers
249 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
45 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
55 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
21 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
19 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
16 views

Error while Saving pandas dataframe to msql database [on hold]

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

Package pytest file with pyinstaller [on hold]

How can I go about packaging a pytest python file with pyinstaller? I currently am tying and get an import error when running the executable ImportError: No module named 'py._builtin'
2
votes
0answers
34 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
30 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
39 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
45 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
42 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
-3
votes
0answers
27 views

Count frequency of specific words in several articles [on hold]

I would like to count the occurrences of a list of words for every article contained in a single text file. Each article can be identified since they all start with a common tag ...
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: ...
3
votes
4answers
143 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
44 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
59 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 ...
0
votes
0answers
19 views

trouble with analyzing words in one file and checking if they are in each line of another file &… [on hold]

So, I am trying to search to see if each of the lines in a file2.txt contain any of the words in file1.txt 1. so if for example: File 1: ...
3
votes
1answer
74 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 ...
-5
votes
0answers
12 views

implementing moving object using cursor keys [closed]

I have a project i am working on my task is to have a player start at a randomly chosen entrance to the maze (a maze might have more than one entrance) and, using the cursor keys, move through the ...
6
votes
2answers
276 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
92 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 ...
-2
votes
0answers
44 views

PYTHON 99% finished code, but need assistance with python reading and adding values in file [closed]

So I have this code, first, it should prompt a user for the name of a file containing keywords (called keywords.txt). It should check to make sure that the file exists and if does not exist then my ...
6
votes
1answer
115 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
82 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: ...
3
votes
1answer
61 views

Abstract graphing-and-timing functions

I like to use timeit to measure performance of small, and sometimes big, functions. However it can be uncertain as to what the 'actual' time to execute the function ...
7
votes
1answer
56 views

Python script for backing up reading information from Goodreads

I’ve written a script for automatically backing up my Goodreads data. This mimics the Export function on the Goodreads website, which returns a CSV file – but this doesn’t require going through a ...
0
votes
1answer
50 views

String reorder by integers

The aim is to have any strings with integers within to be reorder by these integers. Let's say you have the following string: re5 Forty1 cash2 Man3 Booker4 The ...
11
votes
2answers
177 views

Boggle board game solver in Python

I have written a Boggle board solver in Python 3. I would like comments on readability and structure. Thank you! Boggle Boggle is a board game with a 4x4 board of squares, each of which has a letter,...
5
votes
2answers
60 views

Widget setup for Tkinter-based game

I'm thinking of making a little strategic game using tkinter (player should interact with it using buttons). But my code is very repetitive. This is a mock-up of my program: ...
1
vote
2answers
53 views

Infinite prime generator

This code acts as an infinite generator of prime numbers. As new prime numbers are found, they are added to a set. Then, a number x is found to be prime if none of the numbers in the prime set are ...
6
votes
2answers
74 views

Puzzle game - converting binary numbers to decimal

I've been learning Python for a few weeks and I created a simple game where you convert binary numbers to decimal. It shows you n binary numbers and you are supposed to enter the numbers in decimal ...
3
votes
2answers
98 views

Retrieving the nth term of an infinite stream

I recently learned how generators can be infinite in Python. For example, the infinite sequence can be the triangular numbers: $$1, 3, 6, 10,...$$ ...
5
votes
1answer
117 views

Python library for awk-like file manipulation

I recently published a library for advanced awk-like file manipulation in Python 3. The code can be found here and here is the documentation. It is also available for download from pip (...
12
votes
0answers
191 views

Backpropagation in simple Neural Network

I've been working on a simple neural network implemented in python. Currently, it seems to be learning, but unfortunately it doesn't seem to be learning effectively. The graph below shows the output ...
1
vote
1answer
30 views

Calls many stored dataframes, change them and combine them

I call many dataframes (using pickle), then I extract the interesting values of each one and finally combine them. Is there a better way to do it? For example with a for loop call them automatically ...
4
votes
2answers
215 views

Simple Craps game

I'm trying to make my code smaller and less verbose. The pass in the if statement are there because I need to check specifics on the dice roll. The code is ...
4
votes
1answer
44 views

Recursively generating flat XML elements from hierarchical data structure

My class has a method that does some stuff, and then wants to recursively operate on some data. Specifically, I'm generating an XML report whose output includes a flat list of elements derived from a ...
3
votes
1answer
97 views

Password generator in Python 3

I would like to see what you think of a password generator I coded in Python. ...
3
votes
0answers
50 views

Science Buddies derived password cracker

I am trying to improve the performance of this password cracking method: ...
3
votes
2answers
80 views

Matching maximal nodes with velocities

I have written a code which works very good for small data-files (see below). The data file 'WSPL.dat' which I want to evaluate has a size of 2.6 GB and the data file 'VELOC.dat' has a size of 4.3 GB....