Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

learn more… | top users | synonyms

0
votes
3answers
43 views

Generating arithmetic quiz questions

I have created a quiz in Python that will generate a series of 10 questions to test the basic arithmetic skills of primary school children. To do this, I have used a while loop and random functions to ...
0
votes
0answers
16 views

A web crawler for scraping images from stock photo websites

I created a web crawler that uses beautiful soup to crawl images from a website and scrape them to a database. in order to use it you have to create a class that inherits from Crawler and implements 4 ...
6
votes
1answer
88 views

Rock Paper Scissors game in Python

I'm new to programming and I'm trying to teach myself Python through some online books. One of the exercises has me making a Rock Paper Scissors game. The one I have written works well enough I ...
5
votes
2answers
35 views

Parsing mathematical expressions in Reverse Polish Notation

I've wanted to make a calculator for a long time now, so I wrote one of my first parsers, where the input is in reverse polish notation, \$1 \ 1 +\$ becomes \$2\$. It supports to following operators; ...
2
votes
3answers
24 views

Using Python to rename multiple csv files in Windows

I need to rename a large list of csv files that are generated from 3 different servers. The files are produced with a date stamp as the extension, which I need to move in each file name to retain the ...
1
vote
1answer
14 views

Merging tags in two XML files with same attributes and different content

From time to time I translate some Android apps: the developer sends me an XML file, e.g. ...
3
votes
1answer
30 views

Project Euler # 22: Names scores

Problem 22, here, asks the following: Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical ...
4
votes
2answers
42 views

Wikipedia Trie pseudocode in Python

I translated the Wikipedia pseudo-code into Python code (little changes only were required), but I do not like the end result, as it looks like C with all those while loops and counters. The fact is ...
3
votes
1answer
33 views

Web crawlers for three image sites

I'm very new to python and only vaguely remember OOP from doing some Java a few years ago so I don't know what the best way to do this is. I've build a bunch of classes that represent a crawler that ...
6
votes
3answers
56 views

Python Turtle screen saver

Leon asked a question which got closed both here and at Stack Overflow, but I kind of liked the idea, so I implemented a working version of his code, which I now want reviewed. With regards to Leon's ...
-2
votes
0answers
51 views

Is there a more efficient way to do the magic square program in Python [on hold]

I am trying to create a program which gives the output as magic squares and also verifies if the given input comprises a valid magic square. An n × n matrix that is filled with the numbers 1, 2, 3, . ...
4
votes
2answers
66 views

Storing data in the pixels of an image

I've recently redone something I wrote around a year ago since I'd done it wrong (it required the original image to decode an imagine, which can be avoided), so I'm wondering if I could either get ...
2
votes
2answers
31 views

Processing eBay category list for database import

Although I've been programming a fair while I'm learning Python and would like to know how I can make my code more "Pythonic". I'm have a CSV file of eBay categories, containing the name and numeric ...
5
votes
3answers
800 views

“The Minion Game” challenge

This is an implementation of the minion game, which takes in string input and declares a winner between two pre-determined players. The logic is player 1 gets all sequenced words not starting with a ...
4
votes
1answer
35 views

Random Forest Code Optimization

I am new to Python. I have built a model with randomforest in python. But I think my code is not optimized. Please look into my code and suggest if I have deviated from best practices. Overview about ...
-3
votes
1answer
42 views

Style guide on writing long Python code lines [on hold]

When building a working example of a class, I ended up with the following statements which is violating the 80 character rule of PEP8. The code was inside a method inside a class. Code excerpt is ...
1
vote
0answers
25 views

TCP server with user accounts, connection threading, and groups/permissions

This is a TCP server I am currently working on. It is accessed through telnet (I know it isn't secure, its just a project for uni). The server is programmed in Python 3. I am currently trying to ...
1
vote
0answers
12 views

Check duplicate items in Mongodb

I need to query MongoDB and check if an item exists or not: ...
4
votes
2answers
305 views

Simulation of 2 dice rolls

I wrote a program that records how many times 2 fair dice need to be rolled to match the probabilities for each result that we should expect. I think it works but I'm wondering if there's a more ...
6
votes
2answers
55 views

Project Euler #19: Counting Sundays in the 20th century using Pandas

Project Euler #19 asks: How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? I'm hoping I wasn't too off course from the spirit of the ...
5
votes
1answer
29 views

Using changeable column formatting to display table

When answering python tuition calculator v2, I got a little carried away, and started building a print_table() function which I don't like the resulting code for, ...
1
vote
1answer
20 views

Operating multiple columns of one pandas DataFrame using data from another

I have a DataFrame of data from a survey that was repeated over several years, asking people about their income and how much money they had in savings. For simplicity, let's pretend it looks like ...
2
votes
2answers
24 views

Shorthand and nicer python syntax for four options clicking a button

I have a var af_button which is a button on UI. It can be either selected or deselected, so in that case I have four possibilities, which I have implemented. I ...
4
votes
2answers
65 views

Python tuition calculator 2.0

Here is my program that calculates tuition cost for the next five years. I have had some review on it so far, but I am seeking more. Please keep in mind I am new to programming, so I may require a few ...
2
votes
1answer
32 views

Weighted graph from a matrix (list-of-lists)

I created this code while solving the Euler Project problem 83. In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right, by moving left, right, up, and down, is ...
1
vote
2answers
34 views

“Time Conversion” Python implementation

Problem Statement You are given time in AM/PM format. Convert this into a 24 hour format. Note Midnight is \$ 12:00:00AM \$ or \$ 00:00:00 \$ and 12 Noon is \$ 12:00:00PM. \$ Input Format ...
2
votes
1answer
54 views

Binary search function

I have written this function to perform a binary search on an array, given begin/end indices and a value to look for in the supplied array: ...
6
votes
2answers
61 views

Python tuition calculator

I'm a student learning Python, I made this calculator that will tell you the tuition for the next 5 years at an increase of 3% per year. How can I improve on this and did I do anything that isn't best ...
2
votes
1answer
25 views

Save list over many csv files each with given number of lines

I wrote a little code for outputting to csv. It takes a list object named outtext and saves multiple .csv files. Each csv file contains ...
0
votes
0answers
23 views

Python Broken Screensaver [on hold]

Is there another way for me to clean up this code? Someone suggested I update the functions and variable names to be more meaningful. I also understand that I still have to add docstrings and ...
2
votes
2answers
87 views

“Even Tree” Python implementation

Problem Statement You are given a tree (a simple connected graph with no cycles). You have to remove as many edges from the tree as possible to obtain a forest with the condition that : Each ...
13
votes
3answers
266 views

Lexer for C- in Python

I am currently taking a compilers course where we are designing a compiler for C- (which is a subset of C). Our first step was the lexer and I have written that but I believe that it is not very ...
5
votes
2answers
52 views

Python code to run a C program that calculates whether points are in the mandelbrot set

This is part of a project to explore the Mandelbrot set. The code to graphically navigate the complex plane and allow the user to adjust the colormap and number of iterations is all written in Python, ...
0
votes
1answer
30 views

Comparing two lists, boundaries checks and typecasting

This is an automation code written in Python, code is initiated with robotscript. This function validates that my input list matches the list that the program provides me with. I need to do ...
6
votes
4answers
1k views
1
vote
1answer
59 views

The largest odd number (follow-up code using nested functions)

Ask user to input 10 integers and then print the largest odd number that was entered. If no odd number was entered, print a message to that effect. This is my follow-up code on feedback from Find the ...
1
vote
2answers
50 views

Project Euler #4 “Largest Palindrome product” in Python

Given A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product ...
4
votes
3answers
286 views

Find the largest odd number (follow-up code)

Ask user to input 10 integers and then print the largest odd number that was entered. If no odd number was entered, print a message to that effect. This is a follow-up code on feedback from Find the ...
2
votes
2answers
32 views

Finding top most N common character grams in English

I suspect there might be a much more efficient way to accomplish this task. I would appreciate a more clever hint for performance increase. I am also looking for feedback on style and simplification ...
3
votes
2answers
49 views

Binary search attempt

I've heard about the binary search in an intro class I took a couple months ago, remembered how it worked and read this article, so I attempted to write my first binary search in Python. It works, but ...
3
votes
1answer
29 views

“ACM ICPC Team” challenge

I'm attempting this question on HackerRank, which states the follows: You are given a list of \$N\$ people who are attending ACM-ICPC World Finals. Each of them are either well versed in a topic ...
2
votes
2answers
79 views

Find the largest odd number

Ask user to input 10 integers and then print the largest odd number that was entered. If no odd number was entered, print a message to that effect. The above exercise is from chapter 2 of Computation ...
5
votes
2answers
242 views

FizzBuzz for CodeEval

I'm a beginner programmer and decided to try some coding challenges. I found CodeEval and attempted the first challenge, FizzBuzz. However upon submitting my code I found that my submission only ...
11
votes
1answer
541 views

Messed up Elevator Management System

In light of our current community-challenge I decided to build an Elevator Management System. Initially I intended to program the EMS like a real-time operating system and the elevators as ...
5
votes
1answer
57 views

Simple Python + Gtk.Window

I'm learning Python and Gtk so I decided to write a simple application that will take some image let user annotate with a pen and send results through email or save to a file. So far I have the ...
8
votes
4answers
386 views

Print the largest odd number

Ask user to input 10 integers and then print the largest odd number that was entered. If no odd number was entered, print a message to that effect. I've written this code as my solution to the above ...
1
vote
2answers
80 views
-1
votes
0answers
31 views

Vectorize Python function, loop over list of arrays of different sizes [closed]

I would like to vectorize a function (see l_i(t,i) below) and I can't find an easy way. Any help is warmly welcomed! It is used to compute a stochastic process: ...
7
votes
2answers
60 views

Strict types decorator (works only with Python 3.5)

I wrote a decorator which makes Python 3.5 raise exceptions if the arguments that are passed to a type-hinted function are of the wrong type. ...
-4
votes
0answers
32 views