Institute of Computer Science
  1. Courses
  2. 2022/23 fall
  3. Introduction to Programming (MTAT.03.236)
ET
Log in

Introduction to Programming 2022/23 fall

  • Home
  • Grading
  • Links

Homework 7

The deadline is Thursday, the 20th of October, 23:59 (Estonian time).

NB! Make sure that the text files (.txt) are in the same folder as your Python code. Otherwise Python will not find the file.

Exercise 7.1 Failing students

Create the file students.txt containing student names, study book numbers and points (out of 100) that they got in the class. Use ", " as a separator.

students.txt content:

 Benjamin Hummel, B82234, 40
 Janus Alberink, B82694, 95
 Alexandra Peppi, B95274, 50

Create a program that reads data from the file and returns the data about students who failed the course (got less than 51 points).

The output of the program should be:

>>> %Run solution.py
Benjamin Hummel, B82234, 40
Alexandra Peppi, B95274, 50

If you have been struggling with this exercise for some time, maybe you can get help from troubleshooter: https://progtugi.cs.ut.ee#/ts/623af300ef7eaf5634394bf4/. It tries to explain the most common problems and give hints.

Exercise 7.2 US height and weight 2

Write a program that reads people’s height in cm and weight in kg from stats.txt file, converts them to US units of measurement (feet and lb) and then outputs them. You can use the following ratios for your calculations: 1cm = 0.0328ft and 1kg = 2.20lb. Round the results to 1 decimal.

stats.txt content:

 170cm, 60kg
 190cm, 95kg
 160cm, 65kg
 180cm, 75kg

The output of the program should be:

>>> %Run solution.py
5.6ft, 132.0lb
6.2ft, 209.0lb
5.2ft, 143.0lb
5.9ft, 165.0lb

If you have been struggling with this exercise for some time, maybe you can get help from troubleshooter: https://progtugi.cs.ut.ee#/ts/623af5c2ef7eaf5634394c33/. It tries to explain the most common problems and give hints.

Go to Moodle and put your solutions into Exercises 7.

  • 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