Exercise 3¶
Note
Please complete this exercise by 09:00 Wednesday, 25 September 2019.
Start your assignment
You can start working on your copy of Exercise 3 by accepting the GitHub Classroom assignment.
You can also take a look at the template repository for Exercise 3 on GitHub (does not require logging in). Note that you should not try to make changes to this copy of the exercise, but rather only to the copy available via GitHub Classroom.
Warning
Please note that we provide assignment feedback only for students enrolled in the course at the University of Helsinki.
Exercise 3 hints¶
Here are a few things that may be helpful in completing Exercise 3.
General tips¶
- Start by cloning your personal Exercise 3 repository on your (cloud) computer. See instructions for using git from Lesson 2.
- Some code cells contain a line that says: raise NotImplementedError(). Always remove this piece of code from your submission and replace it with your own code. The error tells us if you have not started the exercise.
- Remember to commit your changes often!
- Follow carefully the instructions about variable names and other details (this week’s exercises will bee graded automatically!)
- Ask for help in Slack and/or come to the practical sessions if you get stuck :)
Tests¶
The exercise notebook contains some tests help you see if your code is working correctly.
Combining strings¶
In case you have forgotten, string variables can be added together. For example,
a = "Taco "
b = "time"
c = a + b
print(c)
Nested if statements¶
In some cases it might be useful to have nested if statements, meaning that you have another layer of conditions after the first condition resolves to True.
Take a look of following example:
season = "Winter"
temperature = 10
if season == "Winter":
if temperature > 7:
print("No need for winter jacket!")
else:
print("It might be cold! Wear a proper jacket!")
elif season == "Summer":
if temperature > 20:
print("It's warm! Time to wear shorts!")
else:
print("Well this is Finland, better wear long trousers!")
else:
print("Check the weather forecast!")