Formative Assessment: Groups
Although we provide access to answers for this exercise, we want you to submit the codes you generate via Moodle, so that we can provide feedback. You should avoid looking at the answers before you submit your work. This submitted work does not count towards your course assessment, it is purely to allow us to provide some rapid feedback to you on how you are doing. You will need to put together a few elements from the notes so far to do all parts of this practical, but you should all be capable of doing it well. Pay attention to writing tidy code, with useful, clear comments and document strings.
Exercise 1
- create a list called
months
with the names of the months of the year - create a list called
ndays
with the number of days in each month (for this year) - confirm that the two lists have the same length (12)
- Use these two lists to make a dictionary called
days_in_month
with the key as month name and value as the number of days in that month. - print out the dictionary and confirm it is as expected
- set a variable
m
to be the name of a month - using
m
and your dictionary, print out the number of days in monthm
Last update:
October 8, 2020