Computer Lab 02, variables, conditionals

admin

please check your official faculty email, see http://www.fel.cvut.cz/en/user-info/ for more details. Making the official e-mail address working and reading it regularly is vital. This is the information channel for important messages from the Faculty and also from the course teachers.

practical work

We will practice exercises from Wentworth2012.

  • 2.14.5
  • 2.14.7
  • 2.14.8

input function helps in reading user input. Certain values are naturally positive (greater than zero). Your program should check this and return something like Error: waiting hours must be greater than zero in case the user inserts a negative number.

  • Create a script that reads a number of hours from standard input (and checks whether a number was given), and prints to standard output the corresponding number of days and hours. E.g., when the script gets 51 as the number of hours, it shall print something like 51 hours is 2 days and 3 hours. If you have issues with creating such a string, just print 2 and 3.

homework

  • Read chapters 4 and 5 from the book Wentworth2012. We will not use Turtles, though.

weekly homework 02

  • Create a PyCharm project.
  • Create a 02_weekly_hw.py file (module) inside the project you have just created.
  • Create a variable containing a total number of marks from an exam: 2+3+7+9+0+17+22+8.
  • Write a code which automatically assigns a grade (string) to the mark (integer) according to the table below.
  • The square and round brackets denote closed and open intervals. A closed interval [] includes the number, and open interval () excludes it.
  • Output of your submission should contain only one line with a corresponding grade.
  • Upload the 02_weekly_hw.py file to BRUTE.
Mark Grade
>= 75 First
[70-75) Upper Second
[60-70) Second
[50-60) Third
[45-50) F1 Supp
[40-45) F2
< 40 F3
courses/be5b33prg/labs/week_02.txt · Last modified: 2021/09/30 17:42 by nemymila