Skip to content
6 changes: 5 additions & 1 deletion Lab 01 - Calculator/lab_01_part_a.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#
# The formula for F to C is F-32*5/9=C.
s = input("Enter temperature in Fahrenheit: ")
f = int(s)
c = (f - 32)*5/9
print("The temperature in Celsius:", c, )
12 changes: 11 additions & 1 deletion Lab 01 - Calculator/lab_01_part_b.py
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
#
print('Area of a Trapezoid')
high = input('Enter the height of the trapezoid: ')
lbottom = input('Enter the length of the bottom base: ')
ltop = input('Enter the length of the top base: ')

h = int(high)
lb = int(lbottom)
lt = int(ltop)
a = ((lb + lt) / 2)*h
A = str(a)
print('The area is: ', A, )
5 changes: 4 additions & 1 deletion Lab 01 - Calculator/lab_01_part_c.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#
from math import pi
r = float(input ("Input the radius of the circle : "))
print("The area of the circle with radius " + str(r) + " is: " + str(pi * r**2))

13 changes: 12 additions & 1 deletion Lab 02 - Computer History/Chapter 2 report on video.docx
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
Report goes here
Part 1
https://www.youtube.com/watch?v=sX5g0kidk3Y
Part 2
https://www.youtube.com/watch?v=X7bbQW2RLug
Part 3
https://www.youtube.com/watch?v=6l3gs2UHXGU



Adam Zeh
11/08/17
Report on the Triumph of the Nerds
38 changes: 37 additions & 1 deletion Lab 03 - Create a Quiz/main_program.py
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
#
print("Quiz Time!")


Q1 = input("What is the rarest ore in Minecraft? ")
if Q1 == "Emerald":
print('Correct!')
else:
print('Wrong!')


Q2 = input("What does Pinocchio in Italian mean? ")
if Q2 == "Pine eyes":
print('Correct!')
else:
print('Wrong!')


Q3 = input("In 1992, which US state began offering tourist info at 1-800-33-GUMBO? ")
if Q3 == 'Louisiana':
print('Correct!')
else:
print('Wrong!')


Q4 = input("Proteus orbits what planet of the solar system? ")
if Q4 == 'Neptune':
print('Correct!')
else:
print('Wrong!')


Q5 = input("What is the most popular animal eaten before it's born and after it's dead? ")
if Q5 == 'Chicken':
print('Correct!')
else:
print('Wrong!')

98 changes: 97 additions & 1 deletion Lab 04 - Camel/main_program.py
Original file line number Diff line number Diff line change
@@ -1 +1,97 @@
#
import random

print("Welcome to Camel!")
print("""You have stolen a camel to make your way across the great Mobi desert.
The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.""")
print()

#variables
milesTraveled = 0
thirst = 0
camelFatigue = 0
nativesTraveled = -20
canteen = 3
done = False
oasis = 0

#start main loop
while not done:
nativesBehind = milesTraveled - nativesTraveled
fullSpeed = random.randrange(10, 21)
moderateSpeed = random.randrange(5, 13)
print("""
A. Drink from your canteen.
B. Ahead at moderate speed.
C. Ahead full speed.
D. Stop for the night.
E. Status check
Q. Quit.""")
print()
userInput = input("Your choice? ")
if userInput.lower() == "q":
done = True

#status
elif userInput.lower() == "e":
print("Miles traveled: ",milesTraveled)
print("Drinks in canteen: ",canteen)
print("Your camel has ",camelFatigue,"amount of fatigue.")
print("The natives are ",nativesBehind,"miles behind you.")
#stop for night
elif userInput.lower() == "d":
camelFatigue *= 0
print("Your camel feels refreshed and happy his fatigue is now ",camelFatigue)
nativesTraveled += random.randrange(7, 15)
#move full speed
elif userInput.lower() == "c":
print("You traveled ",fullSpeed,"miles!")
milesTraveled += fullSpeed
thirst += 1
camelFatigue += random.randrange(1, 4)
nativesTraveled += random.randrange(7, 15)
oasis = random.randrange(1, 21)

#move moderate speed
elif userInput.lower() == "b":
print("You traveled ",moderateSpeed,"miles!")
milesTraveled += moderateSpeed
thirst += 1
camelFatigue += 1
nativesTraveled += random.randrange(7, 15)
oasis = random.randrange(1, 21)

#drink canteen
elif userInput.lower() == "a":
if canteen == 0:
print("You're out of water.")
else:
canteen -= 1
thirst *= 0
print("You have ",canteen,"drinks left and you are no longer thirsty.")

#not done check
if oasis == 20:
camelFatigue *= 0
thirst *= 0
canteen = 3
print("You found an oasis! After taking a drink you filled your canteen and the camel is refreshed.")
if nativesBehind <= 15:
print("The natives are drawing near!")
if milesTraveled >= 200 and not done:
print("You made it across the desert, you win!")
done = True
if nativesTraveled >= milesTraveled:
print("The natives caught and beheaded you.")
print("You're dead!")
done = True
if thirst > 4 and thirst <= 6 and not done:
print("You are thirsty")
if thirst > 6:
print("You died of dehydration!")
done = True
if camelFatigue > 5 and camelFatigue <= 8 and not done:
print("Your camel is getting tired.")
if camelFatigue > 8:
print("Your camel is dead.")
done = True

40 changes: 39 additions & 1 deletion Lab 05 - Create a Picture/main_program.py
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
#
#Turtle Tim
import turtle

def draw_diamond(some_turtle):
some_turtle.left(30)
some_turtle.forward(50)
some_turtle.right(60)
some_turtle.forward(50)
some_turtle.right(120)
some_turtle.forward(50)
some_turtle.right(60)
some_turtle.forward(50)
some_turtle.right(150)

def draw_art():
# Instantiate a Screen object, window. Then customize window.
window = turtle.Screen()
window.bgcolor("red") # set background color
# Instantiate a Turtle object, tim. Then customize tim.
tim = turtle.Turtle()
tim.shape("turtle") # see Turtle doc
tim.color("white") # see Turtle doc
tim.speed(2) # 1 (slowest) to 10 (fastest). 0 means no animation.

# Draw a circle with 36 diamonds. We rotate each diamond by 10 degrees at a time.
for i in range (0, 75):
draw_diamond(tim)
tim.right(5)

# Draw a between middle of circle and the floor
tim.right(45)
tim.forward(200)

# How to exit?
window.exitonclick() # click on the window to exit


# Invoke the procedure!
draw_art()
84 changes: 42 additions & 42 deletions Worksheets/worksheet_01.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,71 @@
and punctuation. Please limit the length of each line to 80 characters.

1. Write a line of code that will print your name.

print('Adam')
2. How do you enter a comment in a program?

# hi there
3. What do the following lines of code output?
ALSO: Why do they give a different answer?

print(2 / 3)
print(2 // 3)
print(2 / 3) 0.6
print(2 // 3) 2/3

4. Write a line of code that creates a variable called pi and sets
it to an appropriate value.

from math import pi
pi = pi
5. Why does this code not work?

A = 22
print(a)

one of the variables is not capitalized
6. All of the variable names below can be used. But which ONE of these is
the better variable name to use?

a
a
A
Area
AREA
area
area_of_rectangle
area_of_rectangle <--- this one
Area_Of_Rectangle

7. Which of these variables names are not allowed in Python? (More than one
might be wrong. Also, this question is not asking about improper names, just
names that aren't allowed. Test them if you aren't sure.)

apple
Apple
APPLE
Apple2
1Apple
account number
apple x
Apple x
APPLE x
Apple2 x
1Apple x
account number x
account_number
account.number
accountNumber
account#
pi
accountNumber x
account# x
pi x
PI
fred
Fred
GreatBigVariable
greatBigVariable
fred x
Fred x
GreatBigVariable x
greatBigVariable x
great_big_variable
great.big.variable
2x
great.big.variable x
2x x
x2x
total%
#left
total% x
#left x

8. Why does this code not work?

print(a)
a = 45

the variable needs to be before the print statement
9. Explain the mistake in this code:

pi = float(3.14)

the integer isnt long enough
10. This program runs, but the code still could be better. Explain what is
wrong with the code.

Expand All @@ -78,67 +79,66 @@
pi = x
area = pi * radius ** 2
print(area)

no one knows what x means
11. Explain the mistake in the following code:

x = 4
y = 5
a = ((x) * (y))
print(a)

its a str, not an int statement
12. Explain the mistake in the following code:

x = 4
y = 5
a = 3(x + y)
print(a)

a isnt defined
13. Explain the mistake in the following code:

radius = input(float("Enter the radius:"))

float needs to be before input
14. Do all these print the same value? Which one is better to use and why?

print(2/3+4)
print(2/3+4) <--- this one
print(2 / 3 + 4)
print( 2 / 3+ 4 )

15. What is a constant?

something that stays the same.
16. How are variable names for constants different than other variable names?

they dont change
17. What is a single quote and what is a double quote?
Give and label an example of both.

(/" /") (/' /')
18. Write a Python program that will use escape codes to print a double-quote
and a new line using the Window's standard. (Note: I'm asking for the Window's
standard here. Look it up out of Chapter 1.)

19. Can a Python program print text to the screen using single quotes instead
of double quotes?

yes
20. Why does this code not calculate the average?

print(3 + 4 + 5 / 3)


bc python uses order of operations
21. What is an ``operator'' in Python?

its a math symbol
22. What does the following program print out?

x = 3
x + 1
print(x)
print(x) it prints out 3


23. Correct the following code:

user_name = input("Enter your name: )"
username = input("Enter your name: )"


24. Correct the following code:

value = int(input(print("Enter your age")))
value = int(input("Enter your age"))



Expand Down
Loading