You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 100+ Python challenging programming exercises.txt
+9-5Lines changed: 9 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,10 @@ for i in range(2000, 3201):
34
34
l.append(str(i))
35
35
36
36
print ','.join(l)
37
+
38
+
another solution using list comprehension:
39
+
a= [x for x in range(2000,3201) if (x%7==0 and x%5 != 0)]
40
+
print ','.join(str(x) for x in a)
37
41
#----------------------------------------#
38
42
39
43
#----------------------------------------#
@@ -177,7 +181,7 @@ Level 2
177
181
178
182
Question:
179
183
Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. The element value in the i-th row and j-th column of the array should be i*j.
180
-
Note: i=0,1.., X-1; j=0,1,��Y-1.
184
+
Note: i=0,1.., X-1; j=0,1,¡Y-1.
181
185
Example
182
186
Suppose the following inputs are given to the program:
183
187
3,5
@@ -225,7 +229,7 @@ print ','.join(items)
225
229
Question 9
226
230
Level 2
227
231
228
-
Question��
232
+
Question£º
229
233
Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalized.
230
234
Suppose the following input is supplied to the program:
231
235
Hello world
@@ -425,7 +429,7 @@ Question:
425
429
Write a program that computes the net amount of a bank account based a transaction log from console input. The transaction log format is shown as following:
426
430
D 100
427
431
W 200
428
-
��
432
+
¡
429
433
D means deposit while W means withdrawal.
430
434
Suppose the following input is supplied to the program:
431
435
D 300
@@ -568,13 +572,13 @@ for i in reverse(100):
568
572
Question 21
569
573
Level 3
570
574
571
-
Question��
575
+
Question£º
572
576
A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following:
573
577
UP 5
574
578
DOWN 3
575
579
LEFT 3
576
580
RIGHT 2
577
-
��
581
+
¡
578
582
The numbers after the direction are steps. Please write a program to compute the distance from current position after a sequence of movement and original point. If the distance is a float, then just print the nearest integer.
579
583
Example:
580
584
If the following tuples are given as input to the program:
0 commit comments