Use this tag if you are specifically using Python 2.7. Such questions should be tagged with [python] as well.

learn more… | top users | synonyms

-1
votes
1answer
28 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 ...
4
votes
1answer
29 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 ...
3
votes
1answer
24 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
0answers
9 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
1answer
28 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
25 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
36 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
57 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
2answers
79 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
251 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
4answers
1k views
1
vote
1answer
58 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
47 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
283 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
78 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 ...
11
votes
1answer
524 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 ...
8
votes
4answers
383 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 ...
-4
votes
0answers
20 views

find the repetitions of characters in a string returned as a output [on hold]

Hi guys i am a newbie to programming in python 2.7. I have been told to find the repetitions for all the characters returned as a string in idle by the file provided to us. for example when i run the ...
-4
votes
0answers
31 views
2
votes
1answer
35 views

Creating a time-course dependent, correlation-based directed graph with Networkx

I have a correlation matrix containing 4 time points, each with multiple samples. Each sample is identified with a time point with its name. What I am trying to accomplish here is to create a directed ...
1
vote
1answer
48 views

Passwords storage class

I'm writing a tool, to manage our application, specifically to store passwords in encrypted view. I made a class which is based on two posts: ...
4
votes
1answer
53 views

Strawpoll fetch API in Python

As a beginner to Python with some rookie experience in building software, I decided writing an API wrapper for Strawpoll would be a good exercise in learning the language and design patterns. The ...
1
vote
2answers
51 views

Using break for nested for loop

I want to apply three levels of filtering on record. rec in cname. rec is string of >2 ...
1
vote
1answer
45 views

“Flipping bits” Python implementation

Problem Statement You will be given a list of 32 bits unsigned integers. You are required to output the list of the unsigned integers you get by flipping bits in its binary representation (i.e. ...
4
votes
1answer
42 views

“Lonely Integer” Python implementation

Problem Statement There are N integers in an array A. All but one integer occur in pairs. Your task is to find the number that occurs only once. Input Format The first line of the input ...
2
votes
2answers
23 views

SQLite DB Check and Update Script

My script looks for handshake files in an input folder to determine whether certain processes have completed. If it finds them, it will update the database with the current time stamp. Things I am ...
1
vote
2answers
24 views

Ceasar Cipher by Word Length V.2

Here is an updated version of my Caesar Cipher script. I am looking for ways to improve it, make it more succinct, and expand it's features. I would eventually like to add text import and export ...
4
votes
2answers
60 views

English Checkers game

I've written this English checkers game. Meanwhile, it's a human vs. human game, although it is easily extensible to a game between other players (such as a computer one). ...
4
votes
1answer
201 views
4
votes
4answers
556 views

Plus Minus in Python

You're given an array containing integer values. You need to print the fraction of count of positive numbers, negative numbers and zeroes to the total numbers. Print the value of the fractions ...
5
votes
2answers
56 views

Printing octo-thorpes

Given a number, for example, \$6\$, this Python function should print hashes in the following format: # ## ### #### ##### ###### This is the ...
1
vote
3answers
44 views

Diagonal difference

Given You are given a square matrix of size N×N. Calculate the absolute difference of the sums across the two main diagonals. Input Format The first line contains a single integer N. The ...
9
votes
4answers
537 views

Optimizing Project Euler Solution #12

Just to reiterate my prev. post, as I think it helps structure my weaknesses. Coding methodology: Is the algorithm I used feasible or mostly correct? If not, how do I correct it and why won't it ...
3
votes
1answer
42 views

Multiplying over a matrix

The below code is a solution I put together for the Project Euler #11 question which asked to find the largest product of 4 numbers of any direction in a matrix (horiz, vertic, and diag all ...
7
votes
2answers
407 views

Countdown clock in Python

This project is from the subreddit for beginner Python projects: The goal of the project is to create a program that allows the user to choose a time and date, and then prints out a message at ...
1
vote
3answers
65 views

Read file into list when class is instantiated in Python 2.7

I would like to read a file into a list when I create the class below. Once the list is ready, I would like to access it outside the class in order to process more code based on the list which now ...
3
votes
4answers
96 views

Project Euler #8 - Largest product in series

The problem The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. ...
11
votes
1answer
282 views

Balanced Random Assignment in Python

It has been a very long time since I've used Python. What I'm looking for: I would like to create a 6-by-6 random matrix where each component is either 1 or 2, so that there are 18 ones and 18 twos. ...
9
votes
2answers
416 views

Project Euler #1 Sum of multiples of 3 and 5 python implementation

Given: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. ...
0
votes
2answers
46 views

Argument parser for a word count and/or line count program

How to make code dry in this example? My program is working, but I want to improve it by shorting my code. . ...
2
votes
1answer
32 views

Simple event emitter

I have written a simple event emitter in Python, which allows subscribing to events and emitting events (along with monitoring events too). I'm rather new to Python, and would like some feedback on ...
6
votes
3answers
192 views

A game modeled after Adventure

Here is a little game modeled after adventure that I have been working on. The code initializes a set of lists. It sets a current location randomly generated. The user is tasked with either ...
3
votes
2answers
30 views

Splitting large text file and sorting by content

I have a large text file (~2GB) full of data. The data (sample below) gives an x, y, z coordinate, and a corresponding result on each line (there is other stuff but I don't care about it). The single ...
7
votes
1answer
47 views

Function and method debugging decorator - Part 2

This is a follow-up to this question. I've refactored my previous debugging decorator, and added a couple new features, and changed a few things. Here's a complete list of things that have changed: ...
7
votes
2answers
99 views

Get Wikimedia attributions for images

We are using images from Wikimedia commons for some of Cardshifter's game artwork. I selected some art for each card to make a .jpg file to use in the game clients, ...
5
votes
2answers
61 views

Method and class method debugging decorator

A little while ago in The 2nd Monitor, me and @Phrancis were talking about Python and debugging, and the topic of function decorators came up with this message: Ethan Bierlein: You could even ...
3
votes
3answers
67 views

Calculating a pattern-match score on a ten-element array

I have a method in Python that is extremely slow: ...
5
votes
2answers
257 views

Bank accounts - names, balances and passwords

I'm learning python and I have written a bank program incorporating all the skills I've gathered so far. Using the program, one can create user profiles (name, password, account balance) which will be ...
2
votes
2answers
242 views
-3
votes
0answers
24 views