-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex19.py
39 lines (32 loc) · 1.21 KB
/
ex19.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
37
38
39
# define a function to print out the amount of cheeses and crackers
def cheese_and_crackers(cheese_count, boxes_of_crackers):
print "You have %d cheeses!" % cheese_count
print "You have %d boxes of crackers!" % boxes_of_crackers
print "Man that's enough for a party!"
print "Get a blanket.\n"
# give the number directly to the function
print "We can just give the function numbers directly:"
cheese_and_crackers(20, 30)
# give the number to variable and send them to function
print "Or, we can use variables from our script:"
amount_of_cheese = 10
amount_of_crackers = 50
cheese_and_crackers(amount_of_cheese, amount_of_crackers)
# give the number in math
print "We can even do math inside too:"
cheese_and_crackers(10 + 20, 5 + 6)
# give the variable to math
print "And we can combine the two, ariables and math:"
cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000)
def how_old_are_you(age):
print "you are %d old" % age
my_age = 35
my_age_ten_years_ago = 25
my_wife_age = 34
age_older_than_my_wife = 1
how_old_are_you(35)
how_old_are_you(18+17)
how_old_are_you(my_age)
how_old_are_you(my_wife_age + 1)
how_old_are_you(my_wife_age + age_older_than_my_wife)
how_old_are_you(my_age_ten_years_ago + 10)