Basic (1) P87782


Statement
 

pdf   zip

html

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 x and y.
  3. Write a function integer_division(a, b) that returns the quotient and remainder of the integer division of a by b. Numbers a and b are non negative integers and b≠ 0
  4. Write a function digit_count(n) that given a natural number n returns its number of digits.
  5. Write a function leading_hand(h, m) that given integers 0 ≤ h < 24 and 0 ≤ 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 12 following the clockwise rotation. We assume hour hand has only 12 possible configurations and minute hand has 60.
  6. Write a function update_arrival(h, m, d) that given integers 0 ≤ h < 24 and 0 ≤ m < 60 representing a flight time arrival and d ≥ 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
>>> 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