Homework for Week 1
Videos
In the role of lectures we will use the videos by Chuck Severance from the University of Michigan.
- Watch the videos in YouTube if you need subtitles.
- Presentations used in videos are linked below the video.
- Full text on the topic can be found in the textbook (check the link below the videos).
The videos below are an introduction to programming. They tell why one might want to learn to program, and what are the basic issues when learning how to program.
Slides in English
Textbook in English
Thonny
Thonny is an IDE for Python. In this course we use Thonny as our main programming editor. Please install it, so you can write programs and do homeworks on your own computer.
Thonny comes with Python built in - there is no need to install Python separately. Only Thonny installer is needed to start learning to program.
Please download and install Thonny from
If you have problems with installation, please look at:
Please download and install Thonny from
If you have problems with installation, please look at:
Quizzes
Each week we will have Moodle quizzes on lecture material.
- Each quiz is worth up to 0.5 points.
- Quiz can be answered several times before the deadline, best attempt counts.
Go to Moodle and solve the quiz under Week 1.
Exercises
1. Greeting the user
Write a program that
- Asks for user's name
- Prints a greeting in the form: Hello, <name entered>!
Example
>>> %Run home1.py Enter your name: Robin Hello, Robin! >>>
2. Population density
Copy the following program into Thonny and save it under the name home2.py.
area = int(input("Enter area: ")) population = int(input("Enter population: ")) density = . . . # write formula here print("Average density is", density)
This program should prompt the user for an area and population of a country, then compute the average population density and print it on the screen. The unit of area in this program is square kilometre everywhere.
However, this program misses the correct formula for the average density. Delete the three dots and write a correct formula so that the program outputs the correct average population density of a country.
Submit your solutions
Submit your solutions of exercises 1 and 2 to the autograder in Moodle.
NB! Name the files as home1.py and home2.py, so that autograder can find them.