Category «Input, print and numbers»

School desks

School desks. A school decided to replace the desks in three classrooms. Each desk sits two students. Given the number of students in each class, print the smallest possible number of desks that can be purchased. The program should read three integers: the number of students in each of the three classes, a, b and c respectively. In the first …

Two timestamps

Two timestamps. A timestamp is three numbers: a number of hours, minutes and seconds. Given two timestamps, calculate how many seconds is between them. The moment of the first timestamp occurred before the moment of the second timestamp. Input Output 1 1 1 2 2 2 3661 6 1 30 6 2 10 40 10 …

Previous and next

Previous and next. Write a program that reads an integer number and prints its previous and next numbers. See the examples below for the exact format your answers should take. There shouldn’t be a space before the period. Remember that you can convert the numbers to strings using the function str. Input Output 179 The next …

Apple sharing

Apple sharing. N students take K apples and distribute them among each other evenly. The remaining (the undivisible) part remains in the basket. How many apples will each single student get? How many apples will remain in the basket? The program reads the numbers N and K. It should print the two answers for the questions above. Input Output 6 50 …

Hi John

Hi John. Write a program that greets the person by printing the word “Hi” and the name of the person. See the examples below. Input Output John Hi John Alice Hi Alice Bob Hi Bob Tanner Hi Tanner Jake Hi Jake