Institute of Computer Science
  1. Courses
  2. 2020/21 fall
  3. Introduction to Programming II (MTAT.03.256)
ET
Log in

Introduction to Programming II 2020/21 fall

  • Home
  • Grading
  • Links

Homework 3

The deadline is Sunday, the 29th of November, 23:59 (Estonian time).

Exercise 1. Birthdays

Modify the birthdays program : the program should output top 5 months that have the most birthdays.

Exercise 2. Distances between points

Write a function coordinates that has one argument - point_name. The function has to prompt the user for x and y coordinates of the point and return the coordinates in a tuple.

Write a function distance that takes four coordinates (two coordinates for each point) as its arguments and returns the distance between two points. Hint:

Write a program that asks the user for the coordinates of three points (A, B, C) using function coordinates, finds out and outputs two points that are the closest to each other (use function distance) (you can assume that all distances are different).

Here is an example of the program output:

 Please enter point A x coordinate: 0
 Please enter point A y coordinate: 0
 Please enter point B x coordinate: 3
 Please enter point B y coordinate: 2
 Please enter point C x coordinate: 8
 Please enter point C y coordinate: 9
 Points A and B are the closest to each other.

Go to Moodle and upload your solution into Homework 3.

  • 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