Exercise 19. Functions and Variables
Functions may have been a mind-blowing amount of information, but do not worry. Just keep doing these exercises and going through your checklist from the last exercise and you will eventually get it.
There is one tiny point that you might not have realized, which we’ll reinforce right now. The variables in your function are not connected to the variables in your script. Here’s an exercise to get you thinking about this:
ex19.py
1 def cheese_and_crackers(cheese_count, boxes_of_crackers): 2 print(f"You have {cheese_count} cheeses!") 3 print(f"You have {boxes_of_crackers} boxes of crackers!") 4 print("Man that's enough for a party!") 5 print("Get ...
Get Learn Python 3 the Hard Way: A Very Simple Introduction to the Terrifyingly Beautiful World of Computers and Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.