Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0a66edd

Browse files
Updated file format
1 parent bc4ab8d commit 0a66edd

File tree

1 file changed

+334
-0
lines changed

1 file changed

+334
-0
lines changed

‎Practice_code1.md

Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
This file contains practice question for [Introduction to Python programming](Introduction_to_Python_Programming.ipynb) (input ad output)
2+
3+
Try working online at:
4+
[Coding Ground - Tutorials Point](https://www.tutorialspoint.com/execute_python3_online.php)
5+
[Online Compiler and Debugger](https://www.onlinegdb.com/online_python_compiler)
6+
7+
---
8+
9+
**Q1:** Write a program to print 'Hello World'
10+
11+
---
12+
13+
**Q2:** Write a program to get Name from the user and print it.
14+
>**Sample 1:**
15+
I/p: Chandru
16+
O/p: Chandru
17+
18+
<br>
19+
>**Sample 2:**
20+
I/p: Prabhu
21+
O/p: Prabhu
22+
23+
---
24+
25+
**Q3:** Write a program to get Name and age from user and print it.
26+
27+
>**Sample 1:**
28+
I/p:
29+
Chandru 19
30+
O/p:
31+
Chandru
32+
19
33+
34+
<br>
35+
>**Sample 2:**
36+
I/p:
37+
Prabhu 20
38+
O/p:
39+
Prabhu
40+
20
41+
42+
---
43+
44+
**Q4:** Write a program to get two numbers from user and print their sum
45+
>**Sample 1:**
46+
I/p:
47+
12
48+
12
49+
O/p:
50+
24
51+
52+
<br>
53+
>**Sample 2:**
54+
I/p:
55+
10
56+
15
57+
O/p:
58+
25
59+
60+
---
61+
62+
**Q5:** Write a program to get two numbers and perform all arithmetic operations on them.
63+
64+
---
65+
66+
**Q6:** (Update of **Q4**)
67+
Print formatted output
68+
>**Sample 1:**
69+
I/p:
70+
12
71+
12
72+
O/p:
73+
Sum of 12 and 12 is 24
74+
75+
<br>
76+
>**Sample 2:**
77+
I/p:
78+
10
79+
15
80+
O/p:
81+
Sum of 10 and 15 is 25
82+
83+
---
84+
85+
**Q6:** (Update of **Q4**)
86+
Print formatted output
87+
>**Sample 1:**
88+
I/p:
89+
12
90+
12
91+
O/p:
92+
Sum of 12 and 12 is 24
93+
94+
<br>
95+
>**Sample 2:**
96+
I/p:
97+
10
98+
15
99+
O/p:
100+
Sum of 10 and 15 is 25
101+
102+
---
103+
104+
**Q7:** Write a program to get name from the user and wish them Good Morning
105+
>**Sample:**
106+
I/p: Jenyhin
107+
O/p: Good Morning, Jenyhin
108+
109+
---
110+
111+
**Q8:** Write a program to get the side of the square and print its perimeter
112+
$\text{Perimeter of a square} = 4 \times \rm{side}$
113+
>**Sample 1:**
114+
I/p: 4
115+
O/p: 16
116+
117+
<br>
118+
>**Sample 2:**
119+
I/p: 22
120+
O/p: 88
121+
122+
---
123+
124+
**Q9:** Write a program to get the side of the square and print its area
125+
$\text{Area of square} = \rm{side} \times \rm{side}$
126+
>**Sample 1:**
127+
I/p: 4
128+
O/p: 16
129+
130+
<br>
131+
>**Sample 2:**
132+
I/p: 22
133+
O/p: 484
134+
135+
---
136+
137+
**Q10:** Write a program to get the length and breadth of a rectangle and print its perimeter
138+
$\text{Perimeter of a rectangle} = 2 \times \rm{(length + breadth)}$
139+
>**Sample 1:**
140+
I/p:
141+
4 <br>
142+
4
143+
O/p: 16
144+
145+
<br>
146+
>**Sample 2:**
147+
I/p:
148+
22
149+
21
150+
O/p: 86
151+
152+
---
153+
154+
**Q11:** Write a program to get the length and breadth of a rectangle and print its area
155+
$\text{Area of a rectangle} = \text{length} \times \text{breadth}$
156+
>**Sample 1:**
157+
I/p:
158+
4 <br>
159+
4
160+
O/p: 16
161+
162+
<br>
163+
>**Sample 2:**
164+
I/p:
165+
22
166+
21
167+
O/p: 462
168+
169+
---
170+
171+
**Q12:** Write a program to get the number of sides and length of each side of a regular polygon and print its perimeter.
172+
$\text{Perimeter} = \text{number of sides} \times \text{length of one side}$
173+
>**Sample 1:**
174+
I/p:
175+
8 <br>
176+
4
177+
O/p: 32
178+
179+
<br>
180+
>**Sample 2:**
181+
I/p:
182+
7 <br>
183+
21
184+
O/p: 147
185+
186+
---
187+
188+
**Q13:** Write a program to get the length and height of a right triangle and print its area.
189+
$\text{Area of right triangle} = \dfrac{1}{2} \times \rm{base} \times \rm{height}$
190+
>**Sample 1:**
191+
I/p:
192+
4 <br>
193+
4
194+
O/p: 8.0
195+
196+
<br>
197+
>**Sample 2:**
198+
I/p:
199+
22
200+
21
201+
O/p: 231.0
202+
203+
---
204+
205+
**Q14:** Write a program to get the radius of a circle and print its perimeter rounded off to 3 decimal places. (Take $\pi = 3.14159$)
206+
$\text{Perimeter of a circle} = 2\pi \times \rm{radius}$
207+
>**Sample 1:**
208+
I/p:
209+
4 <br>
210+
O/p: 25.133
211+
212+
<br>
213+
>**Sample 2:**
214+
I/p:
215+
22
216+
O/p: 138.230
217+
218+
---
219+
220+
**Q15:** Write a program to get the radius of a circle and print its area rounded off to 3 decimal places. (Take $\pi = 3.14159$)
221+
$\text{Area of a circle} = \pi \times \rm{radius}^2$
222+
>**Sample 1:**
223+
I/p:
224+
4 <br>
225+
O/p: 50.265
226+
227+
>**Sample 2:**
228+
I/p:
229+
21
230+
O/p: 1385.442
231+
232+
---
233+
234+
**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.
235+
$\text{Area of right triangle} = \sqrt{s \times (s-a)\times(s-b)\times(s-c)}$
236+
$\rm{where},$
237+
$s = \text{Semi-Perimeter} = \dfrac{\text{Perimter of triangle}}{2}$
238+
$a, ~b, ~c = \text{Sides of the triangle}$
239+
>**Sample 1:**
240+
I/p:
241+
3 <br>
242+
4<br>
243+
5
244+
O/p: 6.0
245+
246+
>**Sample 2:**
247+
I/p:
248+
12
249+
21
250+
30
251+
O/p: 98.359
252+
253+
---
254+
255+
**Q17:** Write a program to get the side of a equilateral triangle and print its area rounded off to 4 decimal places.
256+
$\text{Area of equilateral triangle} = \dfrac{\sqrt{3}}{4} \times \rm{side}^2$
257+
>**Sample 1:**
258+
I/p:
259+
4 <br>
260+
O/p: 6.9282
261+
262+
<br>
263+
>**Sample 2:**
264+
I/p:
265+
31
266+
O/p: 416.1252
267+
268+
---
269+
270+
**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.
271+
From Pythagoras theorem, $ \rm{hypotenuse} = \sqrt{\rm{base}^2 + \rm{height}^2}$
272+
>**Sample 1:**
273+
I/p:
274+
3 <br>
275+
4
276+
O/p: 5
277+
278+
<br>
279+
>**Sample 2:**
280+
I/p:
281+
12
282+
6 <br>
283+
O/p: 13.416
284+
285+
---
286+
287+
**Q19:** Write a program to get the side of a cube and print its volume.
288+
$\text{Volume of cube} = \rm{side}^3$
289+
>**Sample 1:**
290+
I/P: 15
291+
O/P: 3375
292+
293+
---
294+
295+
**Q20:** Write a program to get the side of a cube and print its total surface area.
296+
$ \text{T.S.A of Cube} = 6 \times \rm{side}^2$
297+
>**Sample 1:**
298+
I/P: 15
299+
O/P: 1350
300+
301+
---
302+
303+
**Q21:** Write a program to get the side of a cube and print its Lateral surface area.
304+
$\text{L.S.A of cube} = 4 \times \rm{side}^2$
305+
306+
---
307+
308+
**Q22:** Write a program to get the length, breadth and height of a cuboid and print its volume.
309+
$\text{Volume of Cuboid} = \rm{length} \times \rm{breadth} \times \rm{height}$
310+
>**Sample 1:**
311+
I/P:
312+
43
313+
28
314+
35
315+
O/P: 42140
316+
317+
---
318+
319+
**Q23:** Write a program to get the length, breadth and height of a cuboid and print its Total Surface Area.
320+
$\text{T.S.A of Cuboid} = 2 \times ( (\rm{length} \times \rm{breadth}) + (\rm{breadth} \times \rm{height}) + (\rm{height} \times \rm{length}))$
321+
>**Sample 1:**
322+
I/P:
323+
43
324+
28
325+
35
326+
O/P: 7378
327+
328+
---
329+
330+
**Q24:** Write a program to get the length, breadth and height of a cuboid and print its Lateral Surface Area.
331+
$\text{L.S.A of Cuboid} = 2 \times \rm{height} \times (\rm{breadth}+ \rm{length})$
332+
333+
****
334+
**[Check Solution](Solution1.ipynb)**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /