-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex3.py
36 lines (34 loc) · 1.66 KB
/
ex3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# States the Action
print "I will now count my chickens:"
# This adds 25 and 30 then divides by 6
print "Hens", 25.0 + 30 / 6
# I read why it works but I'm still confused about the percent.
print "Roosters", 100.0 - 25 * 3 % 4
# Text noting Line 8's calculation
print "Now I will count the eggs:"
# Calculation from line 6
print 3.0 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6
# States the caluclation for line 12
print "Is it true that 3 + 2 < 5 - 7?"
# Calculation from line 10
print 3.0 + 2 < 5 - 7
# prints string then comma to display result on same line
print "What is 3 + 2?", 3.0 + 2
# same as the line above (These calculations are to show why line 10 is correct.
print "What is 5 - 7?", 5.00 - 7
# another string
print "Oh, that's why it's False."
# another string
print "How about some more."
# showing use of greater-than
print "Is it greater?", 5.0 > -2
# showing use of greater-than-equal
print "Is it greater or equal?", 5.0 >= -2
# showing use of less-than-equal
print "Is it less or equal?", 5.0 <= -2
# Study Drills
#1 Above each line, use the # to write a comment to yourself explaining what the line does.
#2 Remember in Ex 0 when you started python? Start python this way again and using above characters and what you know, use python as a calculator
#3 Find something you need ot calculate and write a new .py file that does it.
#4 Notice the math seems "wrong"? There are no fractions, only whole numbers. Find out why by researching what a "floating point" number is.
#5 Rewrite ex3.py to use floating point numbers so it's more accurate (hint: 20.0 is floating point)