Homework for Week 1
After this week you can
- Use Thonny to write and run programs
- Find and correct errors in your programs
Videos
In the role of lectures, we will use the free lecture videos by Chuck Severance from the University of Michigan.
- The videos have manually created subtitles, if you need them.
- Presentations used in the videos are linked under the videos.
- Full text on the topic can be found in the textbook (link under 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'll 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.
- The quiz can be answered several times before the deadline, the best attempt counts.
Go to Moodle and solve the quiz for Week 1.
Exercises
Also, each week there will be programming exercises.
- Each set of programming exercises is worth up to 0.5 points.
- Each task has an autotester in Moodle, and you can submit your work serval times before the deadline.
- While you are strongly encouraged to do so, there is no obligation to solve all tasks correctly. What counts is the effort you make when trying to solve them.
1. Greeting the user
Write a program that
- Asks for user's name
- Prints a greeting in the form: Hello, <name entered>!
Examples
>>> %Run home1.py
Enter your name: Robin
Hello, Robin!
>>> %Run home1.py
Enter your name: Piibe
Hello, Piibe!
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 kilometers 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 the country.
Enter area: 45339
Enter population: 1328439
Average density is 29.300138953219083
Submit your solutions
Submit your solutions to exercises 1 and 2 to the autotester in Moodle.
NB! Name the files as home1.py and home2.py so that autotester can find them.
How to do the homework
Watch the videos or read the materials before attempting the programming tasks. The videos and materials give an overview of the topic and point out the most important things.
Then solve the quiz, which rehearses the building blocks of the topic, both practical and theoretical. Review the videos if needed. You can solve the quiz many times; try to get as many correct answers as you can.
Finally, solve the programming tasks. It is recommended to test and debug your program locally until you have eliminated all mistakes yourself, and only then submit it to the autotester. Don't worry if you are not able to solve a task on the first attempt. Try again tomorrow, be persistent. Homework is a chance to practice and explore and competence in programming needs time to build.
The list of work for the upcoming week is in Moodle, it is also briefly overviewed in the e-mails sent to the participants through ÕIS. In addition to this work, there may be other tasks or resources available under the current week's material. Please review them, interact with them, but they are not compulsory.
You can always post questions to the course forum or ask the instructor directly. In fact, you are encouraged to do so, the people are glad to help.