Basic (1) X91017


Statement
 

pdf   zip

You have to program several functions. In each case, few lines of code are enough.

  1. Write a function @welcome(name)@ that prints a personalized greeting message. Follow the pattern of the example below.

  2. Write a function @max_min(x, y)@ that returns the maximum and the minimum of two integer numbers xx and yy.

  3. Write a function @integer_division(a, b)@ that returns the quotient and remainder of the integer division of aa by bb. Numbers aa and bb are non negative integers and b0b\not= 0

  4. Write a function @digit_count(n)@ that given a natural number nn returns its number of digits.

  5. Write a function @leading_hand(h, m)@ that given integers 0h<240 \le h < 24 and 0m<600 \le m < 60 representing a digital hour prints the leading hand of an analogical watch pointing out that hour. Depending on value parameters the function prints either "hour hand", "minute hand" or "draw". Leading hand is the one closest to 1212 following the clockwise rotation. We assume hour hand has only 1212 possible configurations and minute hand has 6060.

  6. Write a function @update_arrival(h, m, d)@ that given integers 0h<240 \le h < 24 and 0m<600 \le m < 60 representing a flight time arrival and d0d \ge 0 representing a delay in minutes returns the updated time arrival.

Scoring

Last two functions counts 20 points each one. Previous ones counts 15 points.

Sample session

Sample session
>>> welcome("King Kong")
Hello King Kong, you are welcome!
>>> max_min(-3,5)
(5, -3)
>>> integer_division(14,3)
(4, 2)
>>> digit_count(6543)
4
>>> leading_hand(22,51)
minute hand
>>> update_arrival(23, 57, 5 + 24*60)
(0, 2)
Information
Author
Jorge Castro
Language
English
Translator
Original language
Catalan
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python