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
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -177,7 +177,7 @@ Level 2
177
177
178
178
Question:
179
179
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.
180
+
Note: i=0,1.., X-1; j=0,1,¡Y-1.
181
181
Example
182
182
Suppose the following inputs are given to the program:
183
183
3,5
@@ -225,7 +225,7 @@ print ','.join(items)
225
225
Question 9
226
226
Level 2
227
227
228
-
Question��
228
+
Question£º
229
229
Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalized.
230
230
Suppose the following input is supplied to the program:
231
231
Hello world
@@ -425,7 +425,7 @@ Question:
425
425
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
426
D 100
427
427
W 200
428
-
��
428
+
¡
429
429
D means deposit while W means withdrawal.
430
430
Suppose the following input is supplied to the program:
431
431
D 300
@@ -513,8 +513,8 @@ Question:
513
513
You are required to write a program to sort the (name, age, height) tuples by ascending order where name is string, age and height are numbers. The tuples are input by console. The sort criteria is:
514
514
1: Sort based on name;
515
515
2: Then sort based on age;
516
-
3: Then sort by score.
517
-
The priority is that name > age > score.
516
+
3: Then sort by height.
517
+
The priority is that name > age > height.
518
518
If the following tuples are given as input to the program:
519
519
Tom,19,80
520
520
John,20,90
@@ -560,21 +560,21 @@ def putNumbers(n):
560
560
if j%7==0:
561
561
yield j
562
562
563
-
for i in reverse(100):
563
+
for i in putNumbers(100):
564
564
print i
565
565
#----------------------------------------#
566
566
567
567
#----------------------------------------#
568
568
Question 21
569
569
Level 3
570
570
571
-
Question��
571
+
Question£º
572
572
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
573
UP 5
574
574
DOWN 3
575
575
LEFT 3
576
576
RIGHT 2
577
-
��
577
+
¡
578
578
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
579
Example:
580
580
If the following tuples are given as input to the program:
0 commit comments