Snakify Python Program Solution Input Print and Numbers | Chetan TM

# Tutor Chetan

## Input, Print and Number

1)    Sum of three numbers

Statement

Write a program that takes three numbers and prints their sum. Every number is given on a separate line.

Model solution

• a = int(input())
• b = int(input())
• c = int(input())
• print(a + b + c)

2)    Hi John

Statement

Write a program that greets the person by printing the word "Hi" and the name of the person. See the examples below.

## Model solution

• name = input()
• # Print the result using
• print('Hi', name)

3)    Square

Statement

Write a program that takes a number and print its square.

## Model solution

• a = int(input())
• print(a ** 2)

4)Area of right-angled triangle

Statement

Write a program that reads the length of the base and the height of a right-angled triangle and prints the area. Every number is given on a separate line.

## Model solution

• a = int(input())
• b = int(input())
• print(a * b / 2)

5)  Hello, Harry!

Statement

Write a program that greets the user by printing the word "Hello", a comma, the name of the user and an exclamation mark after it. See the examples below.

Warning. Your program's output should strictly match the desired one, character by character. There shouldn't be any space between the name and the exclamation mark. You can use + operator to concatenate two strings. See the lesson for details.

## Model solution

• print('Hello, ' + input() + '!')

6)  Apple sharing

Statement

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.

## Model solution

• n = int(input())
• k = int(input())
• print(k // n)
• print(k % n)

7)    Previous and next

Statement

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.

## Model solution

• n = int(input())
• print('The next number for the number ' + str(n) + ' is ' + str(n + 1) + '.')
• print('The previous number for the number ' + str(n) + ' is ' + str(n - 1) + '.')

8)    Two timestamps

Statement

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.

## Model solution

• hours_1 = int(input())
• minutes_1 = int(input())
• seconds_1 = int(input())
• hours_2 = int(input())
• minutes_2 = int(input())
• seconds_2 = int(input())
• print(hours_2 * 3600 + minutes_2 * 60 + seconds_2 - hours_1 * 3600 - minutes_1 * 60 - seconds_1)

### 9)    School desks

Statement

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, ab and c respectively.

In the first test there are three groups. The first group has 20 students and thus needs 10 desks. The second group has 21 students, so they can get by with no fewer than 11 desks. 11 desks is also enough for the third group of 22 students. So we need 32 desks in total.

## Model solution

• a = int(input())
• b = int(input())
• c = int(input())
• print(a // 2 + b // 2 + c // 2 + a % 2 + b % 2 + c % 2)

Name

ltr
item
Chetan TM: Snakify Python Program Solution Input Print and Numbers
Snakify Python Program Solution Input Print and Numbers
Python - Programming Language Snakify.org - Problem Solution. 1) Sum of three numbers. 2) Hi John. 3) Square. 4) Area of right-angled triangle.
https://1.bp.blogspot.com/-YjpgdB4NhsI/YGFIdNyvLUI/AAAAAAAAChE/iLQARmF-hKQGlKxtAl3CbVBS9-_cG9ECgCLcBGAsYHQ/s16000/Capture.PNG
https://1.bp.blogspot.com/-YjpgdB4NhsI/YGFIdNyvLUI/AAAAAAAAChE/iLQARmF-hKQGlKxtAl3CbVBS9-_cG9ECgCLcBGAsYHQ/s72-c/Capture.PNG
Chetan TM
http://www.chetantm.com.np/2021/03/snakify-input-print-and-number-python-program-solution.html
http://www.chetantm.com.np/
http://www.chetantm.com.np/
http://www.chetantm.com.np/2021/03/snakify-input-print-and-number-python-program-solution.html
true
5092578752892144998
UTF-8