Contents

What will be the output of the following Python code?
a) a a a a a a                       
b) a
c) no output                         
d) error

b

Explanation: The string x is being shortened by one character in each iteration.


What will be the output of the following Python code?
a) a a a a a a                       
b) a
c) no output                         
d) error

c

Explanation: i is not in x[1:].


What will be the output of the following Python code?
a) a B C D                            
b) a b c d
c) A B C D                            
d) error

b

Explanation: Changes do not happen in-place, rather a new instance of the string is returned.


What will be the output of the following Python code?
a) a b c d                                              
b) A B C D
c) a B C D                            
d) error

b

Explanation: The instance of the string returned by upper() is being printed.


What will be the output of the following Python code?
a) a b c d                                              
b) 0 1 2 3
c) error                                
d) none of these

c

Explanation: range(str) is not allowed.


What will be the output of the following Python code?
a) a b c d                                              
b) 0 1 2 3
c) error                                  
d) 1 2 3 4

b

Explanation: i takes values 0, 1, 2 and 3.