@@ -33,7 +33,7 @@ for i in range(2000, 3201):
33
33
if (i%7==0) and (i%5!=0):
34
34
l.append(str(i))
35
35
36
- print ','.join(l)
36
+ print( ','.join(l) )
37
37
#----------------------------------------#
38
38
39
39
#----------------------------------------#
@@ -57,8 +57,8 @@ def fact(x):
57
57
return 1
58
58
return x * fact(x - 1)
59
59
60
- x=int(raw_input( ))
61
- print fact(x)
60
+ x=int(input("Insert a number: " ))
61
+ print( fact(x) )
62
62
#----------------------------------------#
63
63
64
64
#----------------------------------------#
@@ -77,12 +77,12 @@ In case of input data being supplied to the question, it should be assumed to be
77
77
Consider use dict()
78
78
79
79
Solution:
80
- n=int(raw_input( ))
80
+ n=int(input("Insert a number: " ))
81
81
d=dict()
82
82
for i in range(1,n+1):
83
83
d[i]=i*i
84
84
85
- print d
85
+ print (d)
86
86
#----------------------------------------#
87
87
88
88
#----------------------------------------#
@@ -102,11 +102,11 @@ In case of input data being supplied to the question, it should be assumed to be
102
102
tuple() method can convert list to tuple
103
103
104
104
Solution:
105
- values=raw_input( )
105
+ values=input("Insert a sequence of comma-separated numbers: " )
106
106
l=values.split(",")
107
107
t=tuple(l)
108
- print l
109
- print t
108
+ print (l)
109
+ print (t)
110
110
#----------------------------------------#
111
111
112
112
#----------------------------------------#
@@ -164,11 +164,11 @@ import math
164
164
c=50
165
165
h=30
166
166
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(',')]
168
168
for d in items:
169
169
value.append(str(int(round(math.sqrt(2*c*float(d)/h)))))
170
170
171
- print ','.join(value)
171
+ print ( ','.join(value) )
172
172
#----------------------------------------#
173
173
174
174
#----------------------------------------#
@@ -188,17 +188,17 @@ Hints:
188
188
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.
189
189
190
190
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]
195
195
multilist = [[0 for col in range(colNum)] for row in range(rowNum)]
196
196
197
197
for row in range(rowNum):
198
198
for col in range(colNum):
199
199
multilist[row][col]= row*col
200
200
201
- print multilist
201
+ print ( multilist)
202
202
#----------------------------------------#
203
203
204
204
#----------------------------------------#
0 commit comments