title | subtitle |
---|---|
Input/Output Practice questions |
Practice Code 1 |
This file contains practice question for Introduction to Python programming (input ad output)
Try working online at:
Coding Ground - Tutorials Point
Online Compiler and Debugger
Q1: Write a program to print 'Hello World'
Q2: Write a program to get Name from the user and print it.
Sample 1:
I/p: Chandru
O/p: Chandru
>**Sample 2:** I/p: Prabhu O/p: Prabhu
Q3: Write a program to get Name and age from user and print it.
Sample 1:
I/p:
Chandru 19
O/p:
Chandru
19
>**Sample 2:** I/p: Prabhu 20 O/p: Prabhu 20
Q4: Write a program to get two numbers from user and print their sum
Sample 1:
I/p:
12
12
O/p:
24
>**Sample 2:** I/p: 10 15 O/p: 25
Q5: Write a program to get two numbers and perform all arithmetic operations on them.
Q6: (Update of Q4)
Print formatted output
Sample 1:
I/p:
12
12
O/p:
Sum of 12 and 12 is 24
>**Sample 2:** I/p: 10 15 O/p: Sum of 10 and 15 is 25
Q6: (Update of Q4)
Print formatted output
Sample 1:
I/p:
12
12
O/p:
Sum of 12 and 12 is 24
>**Sample 2:** I/p: 10 15 O/p: Sum of 10 and 15 is 25
Q7: Write a program to get name from the user and wish them Good Morning
Sample:
I/p: Jenyhin
O/p: Good Morning, Jenyhin
Q8: Write a program to get the side of the square and print its perimeter
Sample 1:
I/p: 4
O/p: 16
>**Sample 2:** I/p: 22 O/p: 88
Q9: Write a program to get the side of the square and print its area
Sample 1:
I/p: 4
O/p: 16
>**Sample 2:** I/p: 22 O/p: 484
Q10: Write a program to get the length and breadth of a rectangle and print its perimeter
Sample 1:
I/p:
4
4
O/p: 16
Sample 2:
I/p:
22
21
O/p: 86
Q11: Write a program to get the length and breadth of a rectangle and print its area
Sample 1:
I/p:
4
4
O/p: 16
Sample 2:
I/p:
22
21
O/p: 462
Q12: Write a program to get the number of sides and length of each side of a regular polygon and print its perimeter.
Sample 1:
I/p:
8
4
O/p: 32
Sample 2:
I/p:
7
21
O/p: 147
Q13: Write a program to get the length and height of a right triangle and print its area.
Sample 1:
I/p:
4
4
O/p: 8.0
Sample 2:
I/p:
22
21
O/p: 231.0
Q14: Write a program to get the radius of a circle and print its perimeter rounded off to 3 decimal places. (Take
Sample 1:
I/p:
4
O/p: 25.133
Sample 2:
I/p:
22
O/p: 138.230
Q15: Write a program to get the radius of a circle and print its area rounded off to 3 decimal places. (Take
Sample 1:
I/p:
4
O/p: 50.265
Sample 2:
I/p:
21
O/p: 1385.442
Q16: Write a program to get the sides of a triangle and print its area using Heron's Formula rounded off to 3 decimal places.
Sample 1:
I/p:
3
4
5
O/p: 6.0
Sample 2:
I/p:
12
21
30
O/p: 98.359
Q17: Write a program to get the side of a equilateral triangle and print its area rounded off to 4 decimal places.
Sample 1:
I/p:
4
O/p: 6.9282
Sample 2:
I/p:
31
O/p: 416.1252
Q18: Write a program to get the length and height of a right triangle and print the length of its hypotenuse rounded off to 3 decimal places using Pythagoras Theorem.
From Pythagoras theorem, $ \rm{hypotenuse} = \sqrt{\rm{base}^2 + \rm{height}^2}$
Sample 1:
I/p:
3
4
O/p: 5
Sample 2:
I/p:
12
6
O/p: 13.416
Q19: Write a program to get the side of a cube and print its volume.
Sample 1:
I/P: 15
O/P: 3375
Q20: Write a program to get the side of a cube and print its total surface area.
$ \text{T.S.A of Cube} = 6 \times \rm{side}^2$
Sample 1:
I/P: 15
O/P: 1350
Q21: Write a program to get the side of a cube and print its Lateral surface area.
Q22: Write a program to get the length, breadth and height of a cuboid and print its volume.
Sample 1:
I/P:
43
28
35
O/P: 42140
Q23: Write a program to get the length, breadth and height of a cuboid and print its Total Surface Area.
Sample 1:
I/P:
43
28
35
O/P: 7378
Q24: Write a program to get the length, breadth and height of a cuboid and print its Lateral Surface Area.