Skip to content

Commit 77436fc

Browse files
authored
Update 100+ Python challenging programming exercises.txt
Changes: parenthesis for function "print"
1 parent 54eed14 commit 77436fc

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

100+ Python challenging programming exercises.txt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ for i in range(2000, 3201):
3333
if (i%7==0) and (i%5!=0):
3434
l.append(str(i))
3535

36-
print ','.join(l)
36+
print(','.join(l))
3737
#----------------------------------------#
3838

3939
#----------------------------------------#
@@ -57,8 +57,8 @@ def fact(x):
5757
return 1
5858
return x * fact(x - 1)
5959

60-
x=int(raw_input())
61-
print fact(x)
60+
x=int(input("Insert a number: "))
61+
print(fact(x))
6262
#----------------------------------------#
6363

6464
#----------------------------------------#
@@ -77,12 +77,12 @@ In case of input data being supplied to the question, it should be assumed to be
7777
Consider use dict()
7878

7979
Solution:
80-
n=int(raw_input())
80+
n=int(input("Insert a number: "))
8181
d=dict()
8282
for i in range(1,n+1):
8383
d[i]=i*i
8484

85-
print d
85+
print (d)
8686
#----------------------------------------#
8787

8888
#----------------------------------------#
@@ -102,11 +102,11 @@ In case of input data being supplied to the question, it should be assumed to be
102102
tuple() method can convert list to tuple
103103

104104
Solution:
105-
values=raw_input()
105+
values=input("Insert a sequence of comma-separated numbers: ")
106106
l=values.split(",")
107107
t=tuple(l)
108-
print l
109-
print t
108+
print (l)
109+
print (t)
110110
#----------------------------------------#
111111

112112
#----------------------------------------#
@@ -164,11 +164,11 @@ import math
164164
c=50
165165
h=30
166166
value = []
167-
items=[x for x in raw_input().split(',')]
167+
items=[x for x in input("Insert a sequence of comma-separated numbers: ").split(',')]
168168
for d in items:
169169
value.append(str(int(round(math.sqrt(2*c*float(d)/h)))))
170170

171-
print ','.join(value)
171+
print (','.join(value))
172172
#----------------------------------------#
173173

174174
#----------------------------------------#
@@ -188,17 +188,17 @@ Hints:
188188
Note: In case of input data being supplied to the question, it should be assumed to be a console input in a comma-separated form.
189189

190190
Solution:
191-
input_str = raw_input()
192-
dimensions=[int(x) for x in input_str.split(',')]
193-
rowNum=dimensions[0]
194-
colNum=dimensions[1]
191+
input_str = input("Insert 2 comma-separated digits: ")
192+
dimensions = [int(x) for x in input_str.split(',')]
193+
rowNum = dimensions[0]
194+
colNum = dimensions[1]
195195
multilist = [[0 for col in range(colNum)] for row in range(rowNum)]
196196

197197
for row in range(rowNum):
198198
for col in range(colNum):
199199
multilist[row][col]= row*col
200200

201-
print multilist
201+
print (multilist)
202202
#----------------------------------------#
203203

204204
#----------------------------------------#

0 commit comments

Comments
 (0)