-
Notifications
You must be signed in to change notification settings - Fork 11
/
ex19.py
38 lines (30 loc) · 1.34 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
# Create a cheese_and crackers function that takes two arguments
def cheese_and_crackers(cheese_count, boxes_of_crackers):
# Insert the first argument into a formatted string and display it
print "You have %d cheese!" % cheese_count
# Insert the second argument into a formatted string and display it
print "You have %d boxes of crackers!" % boxes_of_crackers
# Display a string
print "Man that's enough for a party!"
# Display a string with a new line character at the end
print "Get a blanket.\n"
# Display a string
print "We can just give the function numbers directly:"
# Call the cheese_and_crackers function with numbers
cheese_and_crackers(20, 30)
# Display a string
print "Or, we can use variables from our script:"
# Assign the number 10 to the variable amount_of_cheese
amount_of_cheese = 10
# Assign the number 50 to the variable amount_of_crackers
amount_of_crackers = 50
# Call the cheese_and_crackers function using variables
cheese_and_crackers(amount_of_cheese, amount_of_crackers)
# Display a string
print "We can even do math inside too:"
# Call the cheese_and_crackers function with math
cheese_and_crackers(10 + 20, 5 + 6)
# Display a string
print "And we can combine the two, variables and math:"
# Call the cheese_and_crackers function with math, numbers and variables
cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 100)