Topic 2 Homework Questions
Topic 2 Homework Questions
Homework Questions
Python Programming for Economics
Dr. Marcus Roel
Spring 2024, UNNC
Homework
standard-homework: go over our examples from the lecture and (1) understand them,
and (2) vary them slightly to see if you really understand them.
while
Use a while-loop to loop over each persion in the dataset below and print their
name, age, and hobby (maybe nicely formatted) in the dataset dataset =
[['Marcus', 34, 'Running'], ['Lars', 37, 'Play Guitar'],
['Johannes', 45, 'Cycling']]
hint: use len(dataset) to get the number of entries in the (highest level) list.
lists
Create a list (using range) with items
1, 2, ..., 8
5, 6, 7
2, 4, 6, 8, 10
-3, -6, -9
Using the above lists, try to access a single particular value as well as multiple
values using slices
experiment with the other list functions such as append(), pop(), index(), and
remove().
Create a list of lists, where the second dimension lists have the following values
[1,2,3], [4,5,6], and [7,8,9]