🔍
What is the output of the following piece of code when executed in Python  shell?
>>> a=("Check")*3
>>> a
a) (‘Check’,’Check’,’Check’)
b) * Operator not valid for tuples
c) (‘CheckCheckCheck’)
d) Syntax erro
0 like 0 dislike

1 Answer

c) (‘CheckCheckCheck’)
0 like 0 dislike

Related questions

Is the following piece of code valid? >>> a=(1,2,3) >>> b=('A','B','C') >>> c=zip(a,b) a) Yes, c will be ((1,2,3),(‘A’,’B’,’C’)) b) Yes, c will be ((1,2,3),(‘A’,’B’,’C’)) c) No because tuples are immutable d) No because the syntax for zip function isn’t valid

View solution
0 like 0 dislike
0 answers

Suppose d = { john :40, peter :45}, what happens when we try to retrieve a value using the expression d[ susan ]? a) Since susan is not a value in the set, Python raises a KeyError ... Python raises a KeyError exception d) Since susan is not a key in the set, Python raises a syntax error
Answer : c) Since “susan” is not a key in the set, Python raises a KeyError exception...

View solution
0 like 0 dislike
1 answer

What is the output of the following piece of code? >>> a=(0,1,2,3,4) >>> b=slice(0,2) >>> a[b] a) Invalid syntax for slicing b) [0,2]. c) (0,1) d) (0,2)
Answer : c) (0,1)...

View solution
0 like 0 dislike
1 answer

What is the output when following code is executed ? names1 = ['Amir', 'Bear', 'Charlton', 'Daman'] names2 = names1 names3 = names1[:] names2[0] = 'Alice' names3[1] = 'Bob' sum = 0 for ls in (names1, names2, names3): ... if ls[1] == 'Bob': sum += 10 print sum a) 11 b) 12 c) 21 d) 22
Answer : d) 22...

View solution
0 like 0 dislike
1 answer

50.5k questions

47.1k answers

240 comments

7.0k users