Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008.
6
votes
1answer
44 views
Python text game
I've written a simple text game in Python to show you. I would be glad if you would spare a quick look and point out the style errors so I wouldn't pick up bad habits.
...
0
votes
1answer
41 views
Cartesian product of two tuples - python
I'm solving exercise 4 from Discussion 3 of Berkley's CS 61A (2012) (see page 4):
Fill in the definition of cartesian_product. ...
1
vote
3answers
52 views
Minimum element in a tuple
I'm solving exercise 2 from lecture 3 of Berkeley's CS 61A (2012):
Write a function min_element that returns the minimum element in a tuple.
...
-1
votes
1answer
29 views
Map a function to all elements of a tuple
I'm solving exercise 3 from lecture 3 of Berkeley's CS 61A (2012):
Fill in the definition of map_tuple. map_tuple takes in a ...
2
votes
0answers
49 views
Download stock data from Yahoo Finance
This Python 3.4 script downloads stock data and puts it into an Excel file.
...
1
vote
2answers
64 views
Sequence generation problem - Fibonacci
Below is the representation and user interface fib_sequence for generating a Fibonacci sequence:
...
0
votes
1answer
62 views
List comparison algorithm
I am attempting to create an efficient algorithm to pull all of the similar elements between two lists. The problem is two fold. First, I can not seem to find any similar algorithms online. Second, ...
6
votes
4answers
831 views
PyDOS: Version 2.0
This is a follow up question to PyDOS shell simulation.
You might remember PyDOS from my other post. I have now updated it and it's better than ever! Post any ideas below that could make it better.
...
3
votes
2answers
47 views
Evaluate parenthesis expression for correct nesting and matching parens
Please review this solution for matching parens for correctness and nesting.
...
2
votes
2answers
95 views
Sequence processing problems
Problem 1:
Sum the even numbers for the first n fibonacci numbers
Solution:
...
1
vote
1answer
61 views
Python XML - extracting information
I am very new to Python, and also this is my first time trying to parse XML.
I am interested in information within str elements. I can identify that information ...
4
votes
2answers
75 views
Creating lists of events (pitches, velocities, delta-times, durations) from a MIDI track
I am trying to understand good design patterns in Python and I cannot think of a way to break this huge function into smaller parts without making the code cluttered, overly complex or plain ugly.
I ...
3
votes
2answers
122 views
FreeDNS update script
I tried to write a script which takes a list of URLs, checks if their FreeDNS record points to the current IP, and updates the record if not.
Intended use is that the script will be run periodically ...
2
votes
1answer
51 views
Implementation of quicksort algorithm
I'm currently doing an algorithms course and implemented this version of the quicksort algorithm. I would like to know if it is an efficient implementation. I've seen a couple others where there is a ...
3
votes
1answer
46 views
Find the highest number satisfying a condition in an infinite range
I wrote the below function for doing a variation of bisection search that I came up with. This can be useful when the higher bound is not known. It assumes that as number increases the result of the ...
2
votes
1answer
56 views
Non-blocking line-oriented input from several file descriptors
This is a follow-up to Extracting lines from a bytearray ; I got a pretty good answer to the narrow question I asked there, but was invited to show more of the code in case there was a simpler way to ...
1
vote
1answer
22 views
Extracting lines from a bytearray
This class is part of a utility that reads lines from a set of nonblocking file descriptors, blocking only when there are no complete lines to emit.
...
2
votes
2answers
71 views
Interfacing with instruments using pyvisa
I'm new to Python, and after running through some introductory exercises I wrote a class definition for working with some hardware, specifically a Signal Recovery model 7230 lockin amplifier. In the ...
8
votes
1answer
154 views
Scraping my CS teacher's website, then emailing me when the site is updated
I've been working on creating an individual final project for my python CS class that checks my teacher's website on a daily basis and determines if he's changed any of the web pages on his website ...
3
votes
2answers
41 views
Time Code with Microsecond Conversion
The function below converts a time code into seconds, while maintaining the decimal value (fractions of seconds). The time code fed to this function will always contain microseconds. This currently ...
11
votes
3answers
989 views
PyDOS shell simulation
I have a big project called 'PyDOS', written in Python 3.4, and it's going very well. Post your answers of anything that could make it look cleaner.
...
2
votes
2answers
47 views
Interactive HTML stories creator
I decided to write a small script to make writing HTML interactive stories less tedious:
...
4
votes
0answers
58 views
Building Data abstraction and ADT for rectangle using “objects”
For the below given exercise:
Exercise 7: Abstracting Rectangles
Implement a representation for rectangles in a plane. (Hint: You may want to make use of your procedures from exercise 5). ...
7
votes
1answer
77 views
Depth First Backtracking Puzzle Solver
There is this type of puzzle
that can easily be solved with a depth-first backtracking solver. I wrote one in python 3.4 and like to get some feedback.
I'm especially interested in the following ...
2
votes
1answer
33 views
Performance of parsing math functions
I wrote the following code as part of a larger application. This code takes a string that defines a mathematical function on such as r,y x[0], x[1] etc. or any ...
1
vote
1answer
46 views
Building Data abstraction for line segments using “objects”
I follow this definition of "object":...
3
votes
1answer
62 views
Optimizing a Tic-Tac-Toe AI
I built a Tic-Tac-Toe game in Python. The board is made of ASCII characters and it is the user versus an AI. The user chooses a number (1-9) and if the corresponding spot is open then either an 'X' or ...
2
votes
2answers
64 views
Fraction Class in Python
I decided to train myself in OOP with a simple perfect precision Fraction class.
...
0
votes
1answer
74 views
“Data Abstraction” and “Abstract Data Type” for a rational number [closed]
Below is implementation 1 of data abstraction for rational number using functional paradigm written in Python:
...
1
vote
0answers
14 views
2
votes
1answer
33 views
Decision tree for binary classification
I want to become a good Python programmer and so I'd like to know what in my code practices I can improve. Overall I feel like a pretty solid programmer but writing this code felt very "Java" so I am ...
3
votes
3answers
131 views
Optimization of stack frame usage with recursion
For the given below exercise:
Here is one method to check if a number is prime:
...
3
votes
1answer
50 views
Square spiral matrix
I've written a Python script to generate the closest square spiral matrix to a given number.
I'm new to code reviews as a practice, and I'm interested in ways to improve. Please suggest improvements ...
3
votes
1answer
46 views
Factors sieve optimization
I have written a more powerful version of the sieve of Eratosthenes: this sieve returns the number of factors of all the numbers below the limit. Sadly the running ...
3
votes
2answers
63 views
Function returning higher order function
For the below given exercise:
Define a function cycle which takes in three functions as arguments: f1, f2, f3. cycle will then return another function. The returned fuction should take in an ...
0
votes
0answers
42 views
Type checking at runtime
For the below given exercise question:
Many procedures require a certain type of argument. For example, many arithmetic procedures only work if given numeric arguments. If given a non-number, an ...
4
votes
2answers
351 views
Amazon web scraper
I am trying to improve my programming and programming design skills (poor at the moment). I created a small Amazon scraper program. It is a working program. I would be very grateful if you could ...
1
vote
0answers
33 views
Conway's Game of Life in Python3 (follow-up)
I asked for a review of my code, and after making the suggested changes I feel that now the OOP version is clearer in its meaning and overall the code looks cleaner.
...
5
votes
1answer
352 views
Conway's Game of Life in Python3
I've implemented Game of Life in Python for a programming problem, in two different versions: one is a simple script and the other uses a class with a dictionary to initialize the various parameters.
...
8
votes
3answers
353 views
Soundcloud to CSV File
This program connects to Soundcloud and turns the supplied username into a CSV file with the user's like list. The code accomplishes this although it looks rather messy and was wondering what I could ...
4
votes
1answer
63 views
If a message is there, but you cannot see it, is it really there?
I have created a space encoder program, because it is fun to generate invisible messages. (This programme is not cryptographically secure, it is just for fun)
...
2
votes
1answer
129 views
Dumping fields from Python objects
I am writing a small class that has one method: get_state. It is parameterless and returns a dictionary of all the names in self (look in its dict) that are not ...
0
votes
2answers
156 views
Using recursion to count nodes in a binary tree, test equality of linked lists, and find extrema of a linked list
I am working with a some small functions to test recursion. I am fairly new to Python and am wondering if there is a cleaner way to get the job done.
...
1
vote
3answers
68 views
Counting the frequency of letters in a string slices
While preparing a solution for the CodeChef - magic tricks, an easy question about counting the frequency of given character from the string slice, I came up with the following solution:
...
7
votes
2answers
134 views
ASCII-fication of playing cards
I am making a small Blackjack game in Python 3. The part of the code I am unsure about is that which allows me to print nice ASCII versions of the card. ...
6
votes
3answers
271 views
Manipulating CSV files to regular text file
At my job, often I have to manually convert *.csv Files structured like:
number,number\n
number,number\n
number,number\n
...
To a regular *.txt file with the ...
1
vote
0answers
17 views
Removing Graph Nodes of a Specific Type and with Exactly Two Neighbors
Problem Description
I am working with an undirected, weighted graph. It contains two types of nodes, called "A-type" and "B-type". I am starting with a set of ...
4
votes
1answer
74 views
Dictionary with restricted keys
I'm currently building some software that works with systemd unit files, and I've been trying to improve how we construct the unit files.
This is all running in Python 3.4
This first block is the ...
2
votes
2answers
380 views
Failing fast by raising an exception with a custom message
This is a script that utilizes lazy exception throwing. What I do is decorate a function that might throw an exception to throw an exception with a formatted string.
...
2
votes
1answer
71 views
Latitude/longitude waypoint distance calculations, crosstrack, VMG, ETA, etc
I'm in the process of a complete re-write of a stagnant and ill-conceived project. I would like some feedback on the following Python 2.7-3.4 code, before I go any deeper into it.
I would hope it is ...