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

learn more… | top users | synonyms

2
votes
1answer
26 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 ...
5
votes
0answers
56 views

Python program that scrapes my CS teacher's website

I am new to programming, and I'm looking forward to seeing what I can do to improve my code. I've been working on creating an individual final project for my python CS class that checks my teacher's ...
3
votes
2answers
36 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
871 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
43 views

Interactive HTML stories creator

I decided to write a small script to make writing HTML interactive stories less tedious: ...
4
votes
0answers
52 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
57 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
0answers
25 views

Print different results in Python a dictionary [closed]

I'm writing a words unjumble program. Here is my code: ...
2
votes
1answer
30 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
38 views

Building Data abstraction for line segments using “objects”

I follow this definition of "object":...
3
votes
1answer
47 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
51 views

Fraction Class in Python

I decided to train myself in OOP with a simple perfect precision Fraction class. ...
0
votes
1answer
64 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
12 views

CLI wrapper for Yakuake

I have a CLI wrapper for https://yakuake.kde.org/. Python 3.4.*. ...
2
votes
1answer
25 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
125 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
42 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
34 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
56 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
40 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
288 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
19 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
302 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
339 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
60 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
124 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
81 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
60 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
104 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
257 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
13 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
69 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
367 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
59 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 ...
4
votes
1answer
48 views

Converting xy coordinates to theta without discontinutities

This one is, or rather, should be, fairly simple. I have a list of tuples of XY positions, and am trying to pull out angles relative to the origin from it. However, unlike ...
4
votes
1answer
56 views

Class-based user input validation

Having contributed to this Community Wiki on StackOverflow regarding validating user input, I thought I'd finally sit down and write something more robust to do these kinds of tasks. I wanted ...
4
votes
3answers
130 views

Functional programming approach to repeated function application

Control like if..else and while If \$f\$ is a numerical function and \$n\$ is a positive integer, then we can form the ...
8
votes
3answers
194 views

Adding two roman-numeral inputs

This is the first coding class I've taken and I'm not getting much feedback from the instructor. The function of this program is to take two roman numeral inputs, convert them to arabic, add them ...
3
votes
2answers
52 views

Factorisation code running slow

I'm still in the process of learning Python and am doing some of the Project Euler problems. I have made a factorisation algorithm that works; however, it runs really slowly, and I'm not too ...
3
votes
2answers
66 views

Summation and product functions using functional paradigm

Below is the problem: Show that both summation and product are instances of a more general function, called accumulate, with the following signature: ...
2
votes
0answers
45 views

CAPTCHA reader and maker

I've made some CAPTCHA reader and maker in Python using Tkinter. Do you know if it's possible to keep image and output files in "memory" not writing them on disc? Because right now everything is ...
5
votes
5answers
724 views

Simple Rock, Paper, Scissors in Python

I have looked at many different approaches to this game online, but as someone who isn't very experienced with Python, I may not be aware of what others are doing right. Here is my code: ...
3
votes
1answer
38 views

Project Euler #10 in Cython

I'm trying to teach myself some Cython. To do so, I use Project Euler #10: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. 2 Find the sum of all the primes below two million. My Cython ...
3
votes
1answer
108 views

Counting Lines and Sum of Lines

I have a small function that when passed a str that names a file that contains a program; it returns a 2-tuple with the number of the non-empty lines in that program, and the sum of the lengths of all ...
3
votes
2answers
97 views

Recursive functions for sorting

I made a few recursive functions for learning purposes which do a variety of tasks. Here is my current and functioning code: ...
5
votes
2answers
160 views

Functions with mutable and non-mutable named tuples

I am making some functions within a function for learning which when passed information about a named tuple: it returns a reference to a class object from which we can construct instances of the ...
5
votes
1answer
70 views

Flooring cost calculator

I've made a small program that calculates the cost of flooring for a given area based on the price per sqft and total sqft. I have only been programming for a few days now so I am sure that there are ...
0
votes
2answers
82 views

Two permutation iterators for classes in Python with and without a generator

I am just testing out a couple of small classes for learning purposes. Here is my current working code: ...
3
votes
3answers
71 views

Functions taking iterables: peaks, compress, and skipper

I am just testing out a few small functions for learning purposes: ...
4
votes
4answers
198 views

Hailstone Sequences in Python

For the problem given: Douglas Hofstadter’s Pulitzer-prize-winning book, Gödel, Escher, Bach, poses the following mathematical puzzle. Pick a positive integer \$n\$ as the start. If \$n\$ ...