Institute of Computer Science
  1. Courses
  2. 2020/21 spring
  3. Computer Programming (LTAT.03.001)
ET
Log in

Computer Programming 2020/21 spring

  • Home

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.

Windows

Please download and install Thonny from

  • https://thonny.org/

If you have problems with installation, please look at:

  • https://github.com/thonny/thonny/wiki/Windows
OS X

Please download and install Thonny from

  • https://thonny.org/

If you have problems with installation, please look at:

  • https://github.com/thonny/thonny/wiki/MacOSX

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.

  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment