What is Python Programming Online Quiz

1. What is the output when following code is executed ?

>>>str1=”helloworld”

>>>str1[::-1]

 
 
 
 

 2. The output of executing string.ascii_letters can also be achieved by?

 
 
 
 

 3. What is the output when following code is executed ?

>>> str1 = ‘hello’

>>> str2 = ‘,’

>>> str3 = ‘world’

>>> str1[-1:]

 
 
 
 

 4. What is the output of the following?

x = ‘abcd’
for i in range(len(x)):
print(x)
x = ‘a’

 
 
 
 

 5. What is the output of the following?

x = ‘abcd’
for i in range(x):
print(i)

 
 
 
 

 6. What arithmetic operators cannot be used with strings ?

 
 
 
 
 

 7. What error occurs when you execute?

apple = mango
 
 
 
 

8. What is the output of the following?

x = ‘abcd’
for i in x:
print(i.upper())

 
 
 
 

9. What is the output when following statement is executed ?

>>>”a”+”bc”

 
 
 
 

 10. What is the return type of function id ?

 
 
 
 

11. What is the output when following statement is executed ?

>>>print ‘new’ ‘line’

 
 
 
 

12. What is the output of the following?

print(“xyyzxyzxzxyy”.count(‘yy’))

 
 
 
 

 13. What is the output when following code is executed ?

>>>print r”\nhello”

The output is?

 
 
 
 

14. Given a function that does not return any value, What value is thrown by itby default when executed in shell?
 
 
 
 

15. What is the output when following statement is executed ?

>>>print ‘\x97\x98’

 
 
 
 

16. What is the output when following statement is executed ?

>>>”abcd”[2:]

 
 
 
 

17. Which of these in not a core datatype?
 
 
 
 

18. Following set of commands are executed in shell, what will be the output?

>>>str=”hello”

>>>str[:2]

>>>

 
 
 
 

19. Print 0xA + 0xB + 0xC ?
 
 
 
 

20. What is the output of the following?

x = ‘abcd’
for i in x:
print(i)
x.upper()

 
 
 
 
(Visited 17 times, 1 visits today)

Comments

comments

Leave a Reply