What Will Be The Output Of The Following Python Code MCQ
Last updated January 31, 2024 by Jarvis Silva
Are you a python developer looking to brush up your python knowledge and skills then you are at the right place today in this article you will find What will be the output of the following python code MCQ?
I have put up this python MCQ for beginners and expert python programmers as you go forward the difficulty of questions will increase, don’t worry if you don’t know some answers you can click the show answer button to see the answer of a question.
Take a note book or open notepad and track how many questions you got correct, You can test this python code snippet in this online python compiler.
1. What will be the output of the following python code?
text = 'Hello world';
print('text')
- Hello world
- text
- ‘text’
- none of the above
Show Answer
2. What will be the output of the following python code?
text = 'Hello world';
print(text)
- Hello world
- text
- null
- none of the above
Show Answer
3. What will be the output of the following python code?
name = 'Jericho';
newname = 'Jerry';
name = newname;
print(name);
- Jericho
- Jerry
- JerichoJerry
- None of the above
Show Answer
4. What will be the output of the following python code?
name = 'Jericho';
print(f"Hello {name}");
- Hello {name}
- f Hello {name}
- Hello Jericho
- Throw a error
Show Answer
5. What will be the output of the following python code?
for i in range(10):
print(i)
- 0,1,2,3,4,5,6,7,8,9,10
- 0,1,2,3,4,5,6,7,8,9
- 1,2,3,4,5,6,7,8,9,10
- 1,2,3,4,5,6,7,8,9
Show Answer
6. What will be the output of the following python code for i in range(0) print(i)
for i in range(0):
print(i)
- 0
- Infinite
- -1
- Nothing
Show Answer
7. What will be the output of the following python code?
for i in range(2,10):
print(i)
- 0,1,10
- 2,3,4,5,6,7,8,9
- 2,4,6,8
- 2,4,6,8,10
Show Answer
8. What will be the output of the following python code?
for i in range(2,10,2):
print(i)
- 2,2,2,2,2,2,2,2
- 2,3,4,5,6,7,8,9
- 2,4,6,8
- 2,4,6,8,10
Show Answer
9. What will be the output of the following python code snippet i =1 while true
i = 1
while True:
if i%0O7 == 0:
break
print(i)
i += 1
- 1,2,3,4,5,6
- 1,2,3,4,5,6,7
- 1
- 0
Show Answer
10. What will be the output of the following python code?
result = 10 + 1 - 1
print(result)
- 12
- 10
- 9
- 11
Show Answer
11. What will be the output of the following python code snippet 4 + ‘3’
print(4 + '3')
- 43
- 7
- 4’3′
- Throws a error
Show Answer
12. What will be the output of the following python code snippet 4 + ‘3’ Using int()
print(4 + int('3'));
- 43
- 7
- 4’3′
- Throws a error
Show Answer
13. What will be the output of the following python code b=’12’ print(b*2)
b = '12'
print(b * 2)
- 24
- 1212
- 122
- Throws a error
Show Answer
14. What will be the output of the following python code while true?
True = False
while True:
print(True)
break
- True
- False
- Nothing
- Throws a error
Show Answer
15. What will be the output of the following python code?
num1 = 11
num2 = 22
print(num1 * num2 / num2)
- 22
- 11
- 345
- Throws a error
Show Answer
16. What will be the output of the following code snippet?
string = 'Hello world'
print(string.find('hw'))
- 0
- 1
- -1
- Throws a error
Show Answer
17. What will be the output of the following python code snippet?
li = [1,2,3,4]
li.append([5,6,7])
print(li)
- 1,2,3,4,5,6,7
- [1,2,3,4,[5,6,7]]
- [1,2,3,4,5,6,7]
- Throws a error
Show Answer
18. What will be the output of the following python code snippet?
x = {1,2,3,4}
y = {3,4,5}
print(x.difference(y))
- {1,2}
- {1,2,3,4,5}
- {1,2,3,4,{3,4,5}}
- Throws a error
Show Answer
19. What will be the output of the following python code snippet?
def length(a,b):
return a(b)
print(length(len,'python'))
- 5
- None
- 6
- Throws a error
Show Answer
20. What will be the output of the following python code snippet?
def func():
pass
print(type(func()))
- <class ‘function’>
- <class ‘type’>
- <class ‘NoneType’
- None of the above
Show Answer
21. What will be the output of the following python code snippet?
Dict = {1:2,3:4,5:6}
Dict.pop(3,5)
print(Dict)
- {1:2}
- {1:2, 3:4}
- {1:2, 5:6}
- Error
Show Answer
22. What will be the output of the following python code snippet?
List = [3,2.1,'4']
List.sort()
print(List)
- [2.1,2,’4′]
- [2.1,3,4]
- [2.1,3]
- Error
Show Answer
23. What will be the output of the following python code snippet?
s = 0
for i in range(10,1,-1):
s -= i
print(s)
- 55
- -55
- 54
- -54
Show Answer
24. What will be the output of the following python code snippet?
i = o
for i in range(4):
print(i)
- 1,2,3,4
- 0,1,2
- 0,1,2,3
- Error
Show Answer
25. What will be the output of the following python code snippet?
Tuple = (1,2,3)
new_tuple = Tuple,4,5
print(new_tuple)
- (1,2,3,4,5)
- ((1,2,3),4,5)
- 1,2,3,4,5
- Error
Show Answer
So how many you got correct you can tweet your score on Twitter and mention @pythondex. If you want more articles and MCQ like this do join our Telegram channel for updates.
I hope this what will be the output of the following python code MCQ helped you to improve your python knowledge you can find more python guides here – View pythondex guides.
Thank you for reading, Have a nice day 🙂