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 b9e812b

Browse files
Format Updates
1 parent 4867b33 commit b9e812b

File tree

6 files changed

+499
-313
lines changed

6 files changed

+499
-313
lines changed

‎.ipynb_checkpoints/Practice_code4-checkpoint.md

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,24 @@ Try working online at:
44
[Coding Ground - Tutorials Point](https://www.tutorialspoint.com/execute_python3_online.php)
55
[Online Compiler and Debugger](https://www.onlinegdb.com/online_python_compiler)
66

7+
---
8+
79
**Q1:** Write a program to define a function ***multiply*** which get two parameters and returns the product of them.
810

11+
---
12+
13+
914
**Q2:** Write a program to create a function that gets sides of a rectangle and return its perimeter and area.
1015

16+
---
17+
1118
**Q3:** Write a program to create a function that gets a number ***n*** and a value ***s*** and prints the value ***n*** times as output.
12-
>Sample1:
19+
>**Sample 1:**
1320
I/P:
1421
10 <br>
1522
Hello
16-
O/p:
23+
<br>
24+
O/P:
1725
Hello
1826
Hello
1927
Hello
@@ -25,46 +33,71 @@ Hello
2533
Hello
2634
Hello
2735

28-
>Sample2:
36+
<br>
37+
>**Sample 2:**
2938
I/P:
3039
5 <br>
3140
1 <br>
32-
O/p:
41+
<br>
42+
O/P:
3343
1 <br>
3444
1 <br>
3545
1 <br>
3646
1
3747
1
3848

49+
---
50+
3951
**Q4:** Write a program to define a function to determine simple interest for given values of Principal, Rate p.a. and duration in years.
4052
Simple Interest, S.I. = $\dfrac{P \times R \times T}{100}$
4153

54+
---
55+
4256
**Q5:** Write a program to get a number ***n*** and and print the prime numbers from 1 to ***n***. Use function to check if a number is prime or not.
4357

58+
---
59+
4460
**Q6:** Write a program to define a function to return factorial of the number passed in it (use recursion).
4561

62+
---
63+
4664
**Q7:** Write a program to define a function to return factorial of the number passed in it (without recursion).
4765

66+
---
67+
4868
**Q8:** Write a program to define a function that gets a year as input and print if it is a leap year or not.
69+
4970
**Condition:** A year is leap if it is either divisible *4* or *400* and not *100*.
5071

72+
---
73+
5174
**Q9:** Write a program to define a function that returns the permutation of ***n*** and ***r***.<br>
52-
Permutation(n,r) = $^nP_r$ = $\dfrac{n!}{(n-r)!}$
75+
$\text{Permutation(n, r)} = {}^nP_r = \dfrac{n!}{(n-r)!}$
76+
77+
---
5378

5479
**Q10:** Write a program to define a function that returns the permutation of ***n*** and ***r***. Use recursion to compute the factorials.<br>
55-
Permutation(n,r) = $^nP_r$ = $\dfrac{n!}{(n-r)!}$
80+
$\text{Permutation(n, r)} = {}^nP_r = \dfrac{n!}{(n-r)!}$
81+
82+
---
5683

5784
**Q11:** Write a program to define a function that returns the permutation of ***n*** and ***r***.<br>
58-
Permutation(n,r) = $^nP_r$ = $\dfrac{n!}{(n-r)!} = n(n-1)(n-2)...r ~\text{terms}$
85+
$\text{Permutation(n, r)} = {}^nP_r$ = $\dfrac{n!}{(n-r)!} = n(n-1)(n-2)...r ~\text{terms}$
86+
87+
---
5988

6089
**Q12:** Write a program to define a function that returns the combination of ***n*** and ***r***.<br>
61-
Combination(n,r) = $^nC_r$ = $\dfrac{n!}{(n-r)!~r!}$
90+
$\text{Combination(n, r)} = {}^nC_r = \dfrac{n!}{(n-r)!~r!}$
91+
92+
---
6293

6394
**Q13:** Write a program to define a function that returns the combinations of ***n*** and ***r***. Use recursion to compute the factorials.<br>
64-
Combination(n,r) = $^nC_r$ = $\dfrac{n!}{(n-r)!~r!}$
95+
$\text{Combination(n, r)} = {}^nC_r = \dfrac{n!}{(n-r)!~r!}$
96+
97+
---
6598

6699
**Q14:** Write a program to define a function that returns the combinations of ***n*** and ***r***.<br>
67-
Combination(n,r) = $^nC_r$ = $\dfrac{n!}{(n-r)!~r!} = \dfrac{n(n-1)(n-2)...r ~\text{terms}}{1 \times 2 \times 3... r ~\text{(r terms)}} = \displaystyle \prod_{i ~= ~0}^{r ~-~1} \dfrac{n-i}{i+1}$
100+
$\text{Combination(n, r)} = {}^nC_r = \dfrac{n!}{(n-r)!~r!} = \dfrac{n(n-1)(n-2)...r ~\text{terms}}{1 \times 2 \times 3... r ~\text{(r terms)}} = \displaystyle \prod_{i ~= ~0}^{r ~-~1} \dfrac{n-i}{i+1}$
68101

69102
****
70103
**[Check Solution](Solution4.ipynb)**

‎.ipynb_checkpoints/Practice_code5-checkpoint.md

Lines changed: 78 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ Try working online at:
44
[Coding Ground - Tutorials Point](https://www.tutorialspoint.com/execute_python3_online.php)
55
[Online Compiler and Debugger](https://www.onlinegdb.com/online_python_compiler)
66

7+
---
8+
79
**Q1:** Write a program to get a number ***n*** and ***n*** numbers as input and print them as a list.
8-
>Sample 1:
10+
>**Sample 1:**
911
I/p:
1012
3<br>
1113
5<br>
@@ -14,92 +16,126 @@ I/p:
1416
O/p:
1517
[5, 2, -20]
1618

19+
---
20+
1721
**Q2:** Get the list of integers as input, sort them and print as output.
18-
>Sample 1:
22+
>**Sample 1:**
1923
I/P:
2024
-1 110 -10 0 20 1 60
2125
O/P:
2226
[-10 -1 0 1 20 60 110]
2327

28+
---
29+
2430
**Q3:** Get a list of integers as input and print the even elements present in it. (No. of even elements > 1)
25-
>Sample 1:
31+
>**Sample 1:**
2632
I/P: 10 20 5 -2 79 23335 40
2733
O/p: [10 20 -2 40]
2834

35+
---
36+
2937
**Q4:** Write a program to get a list of integers and print their product as output. (Use *reduce* method).
3038
> Sample 1:
3139
I/P: 10 20 5 41 -2 -7 23
3240
O/P: 13202000
3341

42+
---
43+
3444
**Q5:** Write a program to get a list of integers and print their sum as output. (Use *sum* method).
35-
>Sample 1:
45+
>**Sample 1:**
3646
I/P: 10 20 5 41 -2 -7 23
3747
O/P: 90
3848

49+
---
50+
3951
**Q6:** Write a program to get a list of integers and print their sum as output. (use loops).
40-
>Sample 1:
52+
>**Sample 1:**
4153
I/P: 10 20 5 41 -2 -7 23
4254
O/P: 90
4355

56+
---
57+
4458
**Q7:** Write a program to get a list of integers and print their product as output. (Use loops).
45-
>Sample 1:
59+
>**Sample 1:**
4660
I/P: 10 20 5 41 -2 -7 23
4761
O/P: 13202000
4862

63+
---
64+
4965
**Q8:** Write a program to get a list of integers and print their average as output. (round off to 3 decimal places).
50-
>Sample 1:
66+
>**Sample 1:**
5167
I/P: 10 20 5 41 -2 -7 23
5268
O/P: 12.857
5369

70+
---
71+
5472
**Q9:** Write a program to get a list of integers and print the maximum value as output. (Use *max* method).
55-
>Sample 1:
73+
>**Sample 1:**
5674
I/P: 10 20 5 41 -2 -7 23
5775
O/P: 41
5876

77+
---
78+
5979
**Q10:** Write a program to get a list of integers and print the maximum value as output. (Use loops).
60-
>Sample 1:
80+
>**Sample 1:**
6181
I/P: 10 20 5 41 -2 -7 23
6282
O/P: 41
6383

84+
---
85+
6486
**Q11:** Write a program to get a list of integers and print the minimum value as output. (Use *min* method).
65-
>Sample 1:
87+
>**Sample 1:**
6688
I/P: 10 20 5 41 -2 -7 23
6789
O/P: -7
6890

91+
---
92+
6993
**Q12:** Write a program to get a list of integers and print the minimum value as output. (Use loops).
70-
>Sample 1:
94+
>**Sample 1:**
7195
I/P: 10 20 5 41 -2 -7 23
7296
O/P: -7
7397

98+
---
99+
74100
**Q13:** Write a program to get a number ***n*** and print first ***n*** terms of Fibonacci series.
75101

102+
---
103+
76104
**Q14:** Write a program to get a list of string values as input and print the values at even position as output.
77-
>Sample 1:
105+
>**Sample 1:**
78106
I/P: Hi First Second python STRING
79107
O/P: First python
80108

109+
---
110+
81111
**Q15:** Write a program to get a list of numbers as input and print their median as output.
82112
(Median is the center-most value of the sorted list)
83-
>Sample 1:
113+
>**Sample 1:**
84114
I/P: 2 9 1 7 4 8
85115
O/P: 6.5
86116

87-
>Sample 2:
117+
<br>
118+
>**Sample 2:**
88119
I/P: 1 7 8 6 3
89120
O/P: 3
90121

122+
---
123+
91124
**Q16:** Write a program to get a list of numbers as input and print their mode as output.
92125
(Mode is the most frequent value of the given list)
93-
>Sample 1:
126+
>**Sample 1:**
94127
I/P: 2 9 1 1 4 1
95128
O/P: 1
96129

97-
>Sample 2:
130+
<br>
131+
>**Sample 2:**
98132
I/P: 1 3 8 6 3
99133
O/P: 3
100134

135+
---
136+
101137
**Q17:** Write a program to get the number of rows ***n*** and n rows of a matrix and print each row as a list.
102-
>Sample1:
138+
>**Sample 1:**
103139
I/P:
104140
3<br>
105141
10 20 30
@@ -110,8 +146,10 @@ O/P:
110146
[1, 2, 3]
111147
[5, -4, -10]
112148

113-
**Q18:** Write a program to get the number of rows ***n*** and *nxn* matrix and print its transpose.
114-
> Sample1:
149+
---
150+
151+
**Q18:** Write a program to get the number of rows ***n*** and $n\times n$ matrix and print its transpose.
152+
>**Sample1:**
115153
I/P:
116154
3<br>
117155
10 20 30
@@ -122,63 +160,71 @@ O/P:
122160
20 2 -4
123161
30 3 -10
124162

125-
**Q19:** Write a program to get number of rows ***r*** and columns ***c*** and two *rxc* matrices and print their sum as output.
163+
---
164+
165+
**Q19:** Write a program to get number of rows ***r*** and columns ***c*** and two $r \times c$ matrices and print their sum as output.
126166
(No empty lines are provided in between the matrices)
127-
>Sample 1:
167+
>**Sample 1:**
128168
4<br>
129169
4<br>
130170
9 13 5 2
131171
1 11 7 6
132172
3 7 4 1
133-
6 0 7 10 <br><br>
173+
6 0 7 10 <br>
134174
-2 4 7 31
135175
6 9 12 6
136176
12 11 0 1
137-
9 10 2 3 <br><br>
177+
9 10 2 3 <br>
138178
O/P:
139179
7 17 12 33
140180
7 20 19 12
141181
15 18 4 2
142182
15 10 9 13
143183

144-
**Q20:** Write a program to get number of rows ***r*** and no. of columns ***c*** and three *rxc* matrices and print their sum as output.
184+
---
185+
186+
**Q20:** Write a program to get number of rows ***r*** and no. of columns ***c*** and three $r \times c$ matrices and print their sum as output.
145187
(No empty lines are provided in between the matrices)
146-
>Sample 1:
188+
>**Sample 1:**
147189
4<br>
148190
4<br>
149191
9 13 5 2
150192
1 11 7 6
151193
3 7 4 1
152-
6 0 7 10 <br><br>
194+
6 0 7 10 <br>
153195
-2 4 7 31
154196
6 9 12 6
155197
12 11 0 1
156-
9 10 2 3 <br><br>
198+
9 10 2 3 <br>
157199
0 2 8 6
158200
3 7 1 0
159201
0 0 1 2
160-
10 1 0 11 <br><br>
202+
10 1 0 11 <br>
161203
O/P:
162204
7 19 20 39
163205
10 27 20 12
164206
15 18 5 4
165207
25 11 9 24
166208

167-
**Q21:** Write a program to get a *mxn* matrix and a *pxq* matrix (m, n, p, q given) and print their product as output.
209+
---
210+
211+
**Q21:** Write a program to get a $m \times n$ matrix and a $p \times q$ matrix (m, n, p, q given) and print their product as output.
168212
(No empty lines are provided in between the matrices)
169-
>Sample1:
213+
>**Sample1:**
170214
3<br>2<br>
171215
-82 0
172216
-57 -95
173-
91 56 <br><br>
217+
91 56 <br>
174218
2<br>4<br>
175219
1 3 -11 24
176-
-59 42 -15 48 <br><br>
220+
-59 42 -15 48 <br>
177221
O/P:
178222
-82 -246 902 -1968
179223
5548 -4161 2052 -5928
180224
-3213 2625 -1841 4872
181225

226+
---
227+
182228
**Q22:** Write a program to get a list of words and sort them in lexicographic order.
183229

184230
*****

0 commit comments

Comments
(0)

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