ALL THE BEST!!!
PYTHON - HO-AGRA-01ST SEPTEMBER 2024
1 / 50
Which of the following statements correctly assigns multiple variables in one line?
2 / 50
What will be the output of the following code?pythonCopy codedef add(x, y):return x + yresult = add(3, 4)print(result)
3 / 50
What is the output of the following code?pythonCopy codex = Truey = Falseprint(type(x))
4 / 50
What will be the output of the following code?pythonCopy codex = 10if x > 5:print("First block")if x > 8:print("Second block")
5 / 50
Which of the following is a correct way to start a function definition in Python?
6 / 50
Which method is used to add a new key-value pair to a dictionary?
7 / 50
What is the output of the following code?pythonCopy codeprint(10 % 3)
8 / 50
What is a lambda function in Python?
9 / 50
What is inheritance in Python?
10 / 50
What will be the output of the following code?pythonCopy codex = 20if x > 10:if x > 15:print("x is greater than 15")else:print("x is between 10 and 15")else:print("x is less than or equal to 10")
11 / 50
Can a function return multiple values in Python?
12 / 50
Which of the following statements correctly reads an integer input from the user?
13 / 50
What will be the output of the following code?pythonCopy codedef myFunc():print("Hello, World!")myFunc()
14 / 50
What does the continue statement do in a loop?
15 / 50
How do you create a list in Python?
16 / 50
Which of the following is a correct way to create a set in Python?
17 / 50
How do you remove an element from a list by its value?
18 / 50
What will be the output of the following code?pythonCopy codex = 10if x > 5:print("x is greater than 5")else:print("x is less than or equal to 5")
19 / 50
What will be the output of the following code?pythonCopy codemy_dict = {'a' : 1, 'b' : 2, 'c': 3}my_dict['d'] = 4print(my_dict)
20 / 50
What will be the output of the following code?pythonCopy codemy_list = [1, 2, 3]my_list.insert(1, 4)print(my_list)
21 / 50
What is the main characteristic of a set in Python?
22 / 50
What is the result of the following operation?pythonCopy codex = 10y = "20"z = x + y
23 / 50
What is the output of the following code?
pythonCopy codex = "Hello"y = "World"print(x, y, sep=", ")
24 / 50
What will be the output of the following code?pythonCopy codei = 0while i < 5:print(i, end=' ')i += 2
25 / 50
Which of the following will result in an error?
26 / 50
Which of the following will correctly define a function that returns the sum of two numbers?
27 / 50
Which of the following data types is used to represent text data in Python?
28 / 50
What will be the output of the following code?pythonCopy codefor i in range(5):if i == 3:breakprint(i, end=' ')
29 / 50
How do you add an element to a set?
30 / 50
Which of the following is a valid identifier in Python?
31 / 50
What is the correct way to define a function that takes no parameters?
32 / 50
How do you start a comment in Python?
33 / 50
What is the correct syntax for a conditional statement in Python?
34 / 50
Which of the following keywords is used to check multiple conditions in an if-else statement?
35 / 50
What function is used to display output to the screen in Python?
36 / 50
Which of the following statements is true about the __init__ method?
37 / 50
What will be the output of the following code if the user inputs "5"?pythonCopy codex = input("Enter a number")print(x + 10)
38 / 50
What is the purpose of the return statement in a function?
39 / 50
How do you define a class in Python?
40 / 50
How do you take input from the user in Python?
41 / 50
Which method is used to add an element to the end of a list?
42 / 50
What is the output of the following code?pythonCopy codemy_list = [1, 2, 3]print(my_list[1])
43 / 50
What will be the output of the following code?pythonCopy codeclass Dog:def __init__(self, name):self.name = namedog = Dog("Buddy")print(dog.name)
44 / 50
What will be the output of the following code?pythonCopy codeadd = lambda x, y: x + yprint(add(2, 3))
45 / 50
How do you define a function in Python?
46 / 50
What does a function return if it has no return statement?
47 / 50
What is an object in Python?
48 / 50
What will be the output of the following code?pythonCopy codei = 1while i < 10:print(i)
i *= 2
49 / 50
Which of the following keywords is used to define a loop in Python?
50 / 50
What is the purpose of the break statement in a loop?