This article provides 10 multiple-choice questions on fundamental Python concepts and syntax, along with their answers and code snippets. These questions cover topics such as operators, lists, strings, functions, and maps, and are suitable for anyone learning Python, preparing for coding interviews, or testing their knowledge. Whether you are a beginner or an intermediate Python developer, this set of Python MCQs will help you test and improve your understanding of the language.
1 : Basic
What is the output of the following code snippet ?
x = 5
y = 2
print(x % y)
2 : list
What is the output of the following code snippet ?
x = [1, 2, 3, 4, 5]
y = x[1:3]
print(y)
3 : Basic
What is the output of the following code snippet ?
x = "Hello World"
print(x[3:7])
4 : List
What is the output of the following code snippet ?
x = [1, 2, 3]
y = [4, 5, 6]
z = x + y
print(z)
5 : Basic
What is the output of the following code snippet ?
x = 5
y = "6"
print(x + y)
6 : List
What is the output of the following code snippet ?
x = ["apple", "banana","cherry"]
y = [i.upper() for i in x]
print(y)
7
What is the output of the following code snippet ?
x = "banana"
y = "apple"
print(x > y)
8 : Dictionary
What is the output of the following code snippet ?
x = {"name": "John", "age": 30}
y = x.get("gender", "male")
print(y)
9 : List
x = [1, 2, 3, 4, 5]
y = [i * 2 for i in x if i % 2 == 0]
print(y)
10 : Def
def square(x):
return x * x
numbers = [1, 2, 3, 4]
squares = map(square, numbers)
print(list(squares))
You May Be Write Your Score and Suggestions in our Comment Section, Notes Are upload soon. Stayonnected with It,s Quize.
9/10
ReplyDelete