List of exercises and estimated completion times
1a - Python Libraries 5 minutes
1b - Using Functions 10 minutes
1c - Operators 10 minutes
1d - Maze Model 25 minutes
1e - The Maze Population 10 minutes
Relevant Sections: 1.0.2
The directory that contains this workbook also contains a Python
file titled draw_infinity.py
. Import it to a notebook and make the figure in the same way as eight
was drawn in section 1.0.2
Relevant Sections: 1.2.1 to 1.2.5
Try to find the operator or function you need to calculate the following (the easiest way might be an internet search).
What is 2 to the power 15?
Convert "It was the best of times"
to uppercase.
Sort the list [10, 9, 0, 20, 8, 2, 30, 7, 3]
.
What is 100! ? (That is, what is the factorial of 100?) Hint: the factorial
function is in the math
library
Relevant Sections: 1.2.5, 1.3.3
Which of the operators +
, -
, *
, and /
do something useful with the lists [1, 10, 100]
and [5, 4, 7]
?
What happens if you apply the operators +
, -
, *
, /
to a list and a number?
What about a string and a string?
Relevant Sections: 1.5.1, 1.6.1
Work with a partner to design a data structure to represent a maze using dictionaries and lists.
Create an example instance, in a notebook, of a simple structure for your maze:
Make sure that your model:
house = [ "Your answer here" ]
or
house = { "Your answer here" }
Relevant Sections: 1.5.1, 1.6.1, 1.8.1, 1.8.2
Take your maze data structure. Write a program to count the total number of people in the maze, and also determine the total possible occupants.