Complete the following 10 tasks using Python. Each task requires using the input()
function and variables, and performing basic arithmetic operations.
Task: Ask the user to enter two numbers and print their sum.
Example:
Input:
5
7
Output:
12
Task: Ask the user to enter the width and height of a rectangle and print its area.
Example:
Input:
4
6
Output:
24
Task: Ask the user to enter two numbers and print the difference (first minus second).
Example:
Input:
15
8
Output:
7
Task: Ask the user to enter three numbers and print their average.
Example:
Input:
10
15
25
Output:
16.666666666666668
Task: Ask the user to enter a temperature in Celsius and print it in Fahrenheit. (F = C × 1.8 + 32)
Example:
Input:
0
Output:
32.0
Task: Ask the user to enter a number and print its square.
Example:
Input:
9
Output:
81
Task: Ask the user to enter two numbers and print the remainder when the first is divided by the second.
Example:
Input:
20
6
Output:
2
Task: Ask the user to enter a number and print twice its value.
Example:
Input:
13
Output:
26
Task: Ask the user to enter the length of a square's side and print its perimeter.
Example:
Input:
5
Output:
20
Task: Ask the user to enter three numbers and print their product.
Example:
Input:
2
3
4
Output:
24