Unit 2: Unit 2: Python Programming — Mcqs

11th Class Computer Science · Unit 2: Unit 2: Python Programming

0 of 0 answered 0 correct
1.What is Python?
2.Which of the following fields use Python?
3.What is the main purpose of programming?
4.Which step is part of writing a program?
5.Where should you download Python from?
6.What does an IDE help with?
7.Which tool is used to install Python packages?
8.What is the purpose of comments in Python?
9.Which symbol is used for a single-line comment in Python?
  • a `//`
  • b `#`
  • c `/* */`
  • d `--`
10.How can you write a multi-line comment in Python?
11.Which of the following is a valid variable name in Python?
12.Which of the following cannot be used as a variable name in Python?
13.Why should we use meaningful variable names?
14.Which variable name is invalid?
15.Which is allowed in Python variable names?
16.What is the recommended case for constants?
17.What is the data type of the variable in this line: price = 19.99?
18.Which data type represents text in Python?
19.What does the input() function do in Python?
20.How can you convert user input to an integer in Python?
21.What is an operator in Python?
22.Which of the following is an arithmetic operator?
23.Which operator is used for exponentiation?
24.Which operator compares two values and returns True or False?
25.Which of the following is a logical operator?
26.What does the `==` operator check?
27.What is an expression in Python?
28.What is the result of the expression `3 + 4 * 2`?
29.Which has the highest precedence in Python expressions?
30.What will be the output of (3 + 2) * 2`?
31.What are control structures used for in programming?
32.Which of the following is a type of decision-making structure in Python?
33.What does an `if` statement do?
34.Which statement allows checking multiple conditions in order?
35.What is the shorthand version of `if-else` written in one line called?
36.Which loop runs as long as a condition is true?
37.Which loop is best for iterating over a sequence like a list or string?
38.What does the `range(5)` function generate?
39.What does `range(3)` produce?
40.Which of the following is NOT a valid form of the range() function?
41.What is the purpose of the `range()` function in Python?
42.What is a data structure in Python?
43.Which keyword defines a function in Python?
44.How do you use a module in code?
45.Which is a built-in data structure in Python?
46.What is a library in Python?
47.What does `return` do in a function?
48.What are default parameters in functions?
49.Which module works with dates and times?
50.What is a package in Python?
51.Why are packages useful in Python?
52.Which of the following is a built-in data structure in Python?
53.How do you create a list in Python?
54.What will be the output of the following code? fruits = ["Mango", "Apple", "Banana"] print(fruits[1])
55.Which method adds an item to the end of a list?
56.What is the key difference between a tuple and a list?
57.What does the following code do? numbers = [1, 2, 3, 4, 5] slice = numbers[1:4]
58.How can you access the last element of a list?
59.What will be the output of the following code? student_names = ["Ahmed", "Sara", "Ali", "Hina"] student_names.sort() student_names.remove("Sara") print(student_names)
60.What is the purpose of slicing?
61.Why practice indexing and slicing?
62.What is the third element of `[10, 20, 30, 40]`?
63.Which method removes the last item from a list?
64.What is the result of slicing `my_list = [10, 20, 30, 40]; my_list[1:3]`?
65.What is the output of `my_list = [1, 2, 3]; my_list[-1]`?
66.How do you slice a string `s = "Python"` to get `"yth"`?
67.What does `my_list[::2]` do for `[10, 20, 30, 40]`?
68.Which index accesses the last character of a string `s = "Hello"`?
69.What is modular programming?
70.What is the main function in Python?
71.Why is the main() function important?
72.How does modular programming benefit developers?
73.What is Python's standard library?
74.How does the standard library help programmers?
75.What does breaking a program into modules promote?
76.What is a key advantage of using modules?
77.How can you check if a script is run directly?
78.What tasks can the standard library help with?
79.What is Object-Oriented Programming (OOP)?
80.What is a class in Python?
81.What is an object in Python?
82.How does OOP help in code management?
83.What does the `__init__` method do?
84.What does the `describe()` method do?
85.What is the relationship between a class and an object?
86.What does `self` represent?
87.Which OOP principle allows code reuse?
  • a Encapsulation
  • b Inheritance
  • c Polymorphism
  • d All
88.How does OOP make code scalable?
89.What is exception handling in Python?
90.What does the try block do?
91.What happens in the except block?
92.What is the purpose of file handling?
93.How do you open a file in Python?
94.What does the with statement do when handling files?
95.What mode is used to overwrite a file?
96.How do you append data to a file?
97.What does the read() method do?
98.What is the result of dividing by zero in Python?
99.Which block handles exceptions?
100.What error occurs when dividing by zero?
101.Which block always executes, even after an error?
102.What is testing in programming?
103.What is the goal of testing?
104.What is unit testing?
105.What does integration testing check?
106.What is functional testing?
107.What is regression testing?
108.What is debugging?
109.What is a common debugging technique?
110.What does pdb do?
111.Why are error messages important?
112.Which module provides statistical functions like `mean()`?
113.What is the output of `print("Hello", end="")`?
  • a Hello!
  • b Hello
  • c Error
  • d Hello\n
114.What does `lambda x: x * 2` do?
115.What is the output of this code? x = 5 if x % 2 == 0: print("Even") else: print("Odd")
116.What does `range(5)` generate?
117.What is the result of 3**2?