Prof. M. Kadri
What you need to know for midterm 1
Monday March 9th, 2015
Ch02 Input, Processing, and Output
The print function
Reading Input from the Keyboard
Give some equation/fo
triangle_or_not.py - (6 points)
Ask the user for 3 points on the coordinate plane. Calculate the distances
between each comination of points (that is, the length of each potential side
of a triangle), and use those calculations to determine whether or
adventure.py (9 points)
Create the shortest text adventure game ever. The player is in a room with a
chest in it. The player can choose to open the chest or leave it alone. If
they open it, an outcome will be randomly generated.
Ask the player for
grade.py - 3 points
Translate a numeric grade to a letter grade.
1. Ask the user for a numeric grade.
2. Use the table below to calculate the corresponding letter:
90-100 - A
80-89 - B
70-79 - C
60-69 - D
0-59 - F
3. Print out both the number and lett
worksheet.py - (6 points)
Write the output of the following snippets of code. First, write your guess in
a comment, then try running the code. Add a comment showing what you actually
observed after running the code. If there's an error, say there will
tip.py (6 points)
Create a tip calculator.
1. Print out a nice welcome banner!
2. The program should ask the following:
a. How many people?
b. How much did it cost?
c. If there are less 6 people, ask: How was the service?
d. The values that the servic
average_word.py - 7 points
Write a program that asks the user for words. and prints out the longest
word, the shortest word, and the average length of all of the words entered.
* Generate a random number between 3 and 6, inclusive - this will determin
counting.py - 2 points
use *while* loops to do the following:
* print out "while loops"
* use a while loop to count from 2 up-to and including 10 by 2's.
* use another while loop to count down from 5 down to 1
use *for* loops to do the following:
flagged.py - 7 points
Create a program that generates a pattern for a flag.
* ask the user for a width of the flag
* the width should be greater than 0
* if it isn't, ask again until the user enters a valid value
* then. ask the user for a character
many_words.py - 4 points
Write a program that asks for a number. and then proceeds to ask for that
number of words. The program should print the words in reverse order at the end
of the program.
Hint 1: if you use a for loop to do this, but make the e
numbers.py (5 points)
Write a program that outputs the number in the thousands, hundreds, tens and
ones places of a number.
Create a file called numbers.py
Ask the user for a number
Calculate the numbers in the thousands, hundreds, tens
grade_bot_3000.py (7 points)
You've been hired as a grader for several classes, and the total number of
students you have to grade are over a 1000 (ughhh). Calculating grades by hand
for all of those students would drive you INSANE. . So you create a
multiply.py (3 points)
Write a program that:
* asks the user for a number
* prints out a table of that number multiplied by the first 7 prime numbers:
2, 3, 5, 7, 11, 13, 17
* it will format the output so that the original number and the prime number
Programming Project #1
This assignment will give you experience on the use of:
1. Integers and floats
2. Mathematical operations
3. The float(), int(), round(), print(), and input()functions
4. Importing a Python module
# Intro to Comp Prog 02
# Assign 7 (Prob 1a)
username = input ("Enter a username: ")
# determine the size of the username
size_of_username = len(username)
if size_of_username < 8 or size_of_username > 15:
valid_size = False
veg1=input("What is your first favourite vegetable?\n>")
veg2=input("What is your second favourite vegetable?\n>")
veg3=input("What is your third favourite vegetable?\n>")
print(veg1, veg2, veg3, sep=", ")
print("our man on the road, he " + verb4 + " promo")
print("You said, Keep our business on the low-low")
print("I'm just tryna " + verb1 + " you out the friend zone")
print("Cause you " + verb2 + " even
change_puhleese.py (15 points) (1 point extra credit)
You're the manager of a tiny boutique that sells Python related gifts and
knick-knacks (like plush Python stuffed animals, Guido Van Rossum bobble head
dolls, etc. ). Unfortunately, you don't have
sticky.py - 12 points
Create a game of pick-up sticks where the player plays against the computer.
Pick-up Sticks Rules
* there are some number of sticks on the table
* 2 player alternate turns picking up 1, 2 or 3 sticks
* the player that picks up th