Question 1
What is the correct way to check if a key exists in a dictionary?
Question 2
What is the output of the following code snippet?
x = [1,2,3]
y = x
y[0] = 10
print(x[0])
Question 3
How do you check if a value exists in a dictionary in python?
Question 4
What is the correct way to open a file in python for reading?
Question 5
What is the purpose of the try andexcept blocks in Python?
Question 6
What of the following is a correct way to define a function in python?
Question 7
What is the output of the following code snippet?
my_dict ={"a": 1. "b": 2, "c": 3}
print(len(my_dict))
Question 8
What is the output of the following code snippet?
a = [1, 2, 3]
b = a
b[0] = 5
print (a[0])
Question 9
What is the output of the following code snippet?
Question 10
Which of the following is a correct way to create a copy of a list in python?
Question 11
What does the pop() method do for lists in python?
Question 12
What is the output of the following code snippet?
x = True
y = False
print(x and y)
Question 13
How do you convert a list into a tuple?
Question 14
Which of the following is a correct way to define a class in python?
Question 15
What is the output of the following code snippet?
Question 16
How do you define a set in python?
Question 17
What is the output of the following code snippet?
x = "hello, world!"
print(x.split(","))
Question 18
What is the output of the following code snippet?
x = "hello"
y = "world"
print(x + y)
Question 19
How do you remove an element from a set in python
Question 20
Which statement is used to exit from a loop in python?
Question 21
What is the output of the following code snippet?
x = [1,2,3]
y = [4,5]
z = x + y
print(len(z))
Question 22
Which function is used to convert a string to lowercase in python?
Question 23
What is the purpose of the pass statement in python?
Question 24
Which of the following data types is mutable in python?
Question 25
Which character is used for single-line comments in python?
Question 26
How do you access the last element of a list in python?
Question 27
What is the output of the following code snippet?
Question 28
What is the output of the following code snippet?
my_list = [1,2,3,4,5]
print(my_list[-3])
Question 29
What is the output of the following code snippet?
x =10
y =20
x, y = y, x
print (x)
Question 30
What is python?
Question 31
What is the output of the following code snippet?
my_tuple = (1, 2, 3, 4, 5)
print(my_tuple[1:3])
Question 32
What is the output of the following code snippet?
Question 33
What is the output of the following code snippet?
my_list = [1, 2, 3, 4]
print (my_list[2])
Question 34
What is the output of the following code snippet?
my_string = "Hello, World!"
print(my_string[::2])
Question 35
How do you convert a string to an integer in python?
Question 36
What is the output of the following code snippet?
Question 37
What is the output of the following code snippet?
my_string = "Hello, world!"
print (my_string[-1])
Question 38
What does the range()function return?
Question 39
What is the result of the expression?
Question 40
Which of the following is not a valid python variable name?
Question 41
What is the correct way to define an empty list in python?
Question 42
What is the output of the following code snippet?
my_set ={1, 2, 3, 4}
my_set.add(5)
print(my_set)
Question 43
Which of the following is a correct way to define a tuple in python?
Question 44
What is the output of the following code snippet?
x = "Hello, World!"
print(x.upper())
Question 45
What does the len()function do in python?
Question 46
Which operator is used for exponentiation in python?
Question 47
What is the output of the following code snippet?
Question 48
What does the ord () function do in python?
Question 49
What is the purpose of the random module in python?
Question 50
Which of the following is used to take user input in python?