February 2024
Beginner
352 pages
8h 16m
English
In this exercise, we’re going to do something fun by combining functions with dicts. The purpose of this exercise is to confirm that you can combine different things in Python. Combination is a key aspect of programming, and you’ll find that many “complex” concepts are nothing more than a combination of simpler concepts.
To prepare we first have to confirm that a function’s name is just like other variables. Take a look at this code:
1 def print_number(x):
2 print("NUMBER IS", x)
3
4 rename_print = print_number
5 rename_print(100)
6 print_number(100)
If you run this code, you’ll see that rename_print does the exact same thing as print_number ...
Read now
Unlock full access