@@ -4,8 +4,10 @@ Try working online at:
4
4
[ Coding Ground - Tutorials Point] ( https://www.tutorialspoint.com/execute_python3_online.php )
5
5
[ Online Compiler and Debugger] ( https://www.onlinegdb.com/online_python_compiler )
6
6
7
+ ---
8
+
7
9
** 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:**
9
11
I/p:
10
12
3<br >
11
13
5<br >
@@ -14,92 +16,126 @@ I/p:
14
16
O/p:
15
17
[ 5, 2, -20]
16
18
19
+ ---
20
+
17
21
** Q2:** Get the list of integers as input, sort them and print as output.
18
- > Sample 1:
22
+ > ** Sample 1:**
19
23
I/P:
20
24
-1 110 -10 0 20 1 60
21
25
O/P:
22
26
[ -10 -1 0 1 20 60 110]
23
27
28
+ ---
29
+
24
30
** 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:**
26
32
I/P: 10 20 5 -2 79 23335 40
27
33
O/p: [ 10 20 -2 40]
28
34
35
+ ---
36
+
29
37
** Q4:** Write a program to get a list of integers and print their product as output. (Use * reduce* method).
30
38
> Sample 1:
31
39
I/P: 10 20 5 41 -2 -7 23
32
40
O/P: 13202000
33
41
42
+ ---
43
+
34
44
** 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:**
36
46
I/P: 10 20 5 41 -2 -7 23
37
47
O/P: 90
38
48
49
+ ---
50
+
39
51
** Q6:** Write a program to get a list of integers and print their sum as output. (use loops).
40
- > Sample 1:
52
+ > ** Sample 1:**
41
53
I/P: 10 20 5 41 -2 -7 23
42
54
O/P: 90
43
55
56
+ ---
57
+
44
58
** Q7:** Write a program to get a list of integers and print their product as output. (Use loops).
45
- > Sample 1:
59
+ > ** Sample 1:**
46
60
I/P: 10 20 5 41 -2 -7 23
47
61
O/P: 13202000
48
62
63
+ ---
64
+
49
65
** 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:**
51
67
I/P: 10 20 5 41 -2 -7 23
52
68
O/P: 12.857
53
69
70
+ ---
71
+
54
72
** 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:**
56
74
I/P: 10 20 5 41 -2 -7 23
57
75
O/P: 41
58
76
77
+ ---
78
+
59
79
** 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:**
61
81
I/P: 10 20 5 41 -2 -7 23
62
82
O/P: 41
63
83
84
+ ---
85
+
64
86
** 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:**
66
88
I/P: 10 20 5 41 -2 -7 23
67
89
O/P: -7
68
90
91
+ ---
92
+
69
93
** 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:**
71
95
I/P: 10 20 5 41 -2 -7 23
72
96
O/P: -7
73
97
98
+ ---
99
+
74
100
** Q13:** Write a program to get a number *** n*** and print first *** n*** terms of Fibonacci series.
75
101
102
+ ---
103
+
76
104
** 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:**
78
106
I/P: Hi First Second python STRING
79
107
O/P: First python
80
108
109
+ ---
110
+
81
111
** Q15:** Write a program to get a list of numbers as input and print their median as output.
82
112
(Median is the center-most value of the sorted list)
83
- > Sample 1:
113
+ > ** Sample 1:**
84
114
I/P: 2 9 1 7 4 8
85
115
O/P: 6.5
86
116
87
- > Sample 2:
117
+ <br >
118
+ > ** Sample 2:**
88
119
I/P: 1 7 8 6 3
89
120
O/P: 3
90
121
122
+ ---
123
+
91
124
** Q16:** Write a program to get a list of numbers as input and print their mode as output.
92
125
(Mode is the most frequent value of the given list)
93
- > Sample 1:
126
+ > ** Sample 1:**
94
127
I/P: 2 9 1 1 4 1
95
128
O/P: 1
96
129
97
- > Sample 2:
130
+ <br >
131
+ > ** Sample 2:**
98
132
I/P: 1 3 8 6 3
99
133
O/P: 3
100
134
135
+ ---
136
+
101
137
** 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: **
103
139
I/P:
104
140
3<br >
105
141
10 20 30
@@ -110,8 +146,10 @@ O/P:
110
146
[ 1, 2, 3]
111
147
[ 5, -4, -10]
112
148
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:**
115
153
I/P:
116
154
3<br >
117
155
10 20 30
@@ -122,63 +160,71 @@ O/P:
122
160
20 2 -4
123
161
30 3 -10
124
162
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.
126
166
(No empty lines are provided in between the matrices)
127
- > Sample 1:
167
+ > ** Sample 1:**
128
168
4<br>
129
169
4<br>
130
170
9 13 5 2
131
171
1 11 7 6
132
172
3 7 4 1
133
- 6 0 7 10 < br > <br >
173
+ 6 0 7 10 <br >
134
174
-2 4 7 31
135
175
6 9 12 6
136
176
12 11 0 1
137
- 9 10 2 3 < br > <br >
177
+ 9 10 2 3 <br >
138
178
O/P:
139
179
7 17 12 33
140
180
7 20 19 12
141
181
15 18 4 2
142
182
15 10 9 13
143
183
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.
145
187
(No empty lines are provided in between the matrices)
146
- > Sample 1:
188
+ > ** Sample 1:**
147
189
4<br>
148
190
4<br>
149
191
9 13 5 2
150
192
1 11 7 6
151
193
3 7 4 1
152
- 6 0 7 10 < br > <br >
194
+ 6 0 7 10 <br >
153
195
-2 4 7 31
154
196
6 9 12 6
155
197
12 11 0 1
156
- 9 10 2 3 < br > <br >
198
+ 9 10 2 3 <br >
157
199
0 2 8 6
158
200
3 7 1 0
159
201
0 0 1 2
160
- 10 1 0 11 < br > <br >
202
+ 10 1 0 11 <br >
161
203
O/P:
162
204
7 19 20 39
163
205
10 27 20 12
164
206
15 18 5 4
165
207
25 11 9 24
166
208
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.
168
212
(No empty lines are provided in between the matrices)
169
- > Sample1:
213
+ > ** Sample1:**
170
214
3<br> 2<br >
171
215
-82 0
172
216
-57 -95
173
- 91 56 < br > <br >
217
+ 91 56 <br >
174
218
2<br >4<br >
175
219
1 3 -11 24
176
- -59 42 -15 48 <br >< br >
220
+ -59 42 -15 48 <br >
177
221
O/P:
178
222
-82 -246 902 -1968
179
223
5548 -4161 2052 -5928
180
224
-3213 2625 -1841 4872
181
225
226
+ ---
227
+
182
228
** Q22:** Write a program to get a list of words and sort them in lexicographic order.
183
229
184
230
*****
0 commit comments