CS 9 Oqb3 2425 Sa (Ai-Python)
CS 9 Oqb3 2425 Sa (Ai-Python)
28. Which of the following variable names follows all the rules for valid identifiers in Python?
A. 99bottles C. bottle-99
B. bottle99 D. bottle@99
31. Which of the following is an example of an integer (int) data type in Python?
A. 3.14 C. -48.6
B. "20" D. 10
33. What data type would be used to store a student's address in Python?
A. int C. str
B. float D. bool
34. Which of the following is NOT a valid example of a string (str) data type?
A. "Hello" C. 12345
B. '218' D. 'Peace'
36. Which of the following values is considered as False in a boolean context in Python?
A. 1 C. -1
B. 0 D. 2.5
37. Which function is used to print a message or value on the console in Python?
A. input() C. print()
B. write() D. display()
38. What will be the output of the following code: print("Hello, World!")?
A. Hello, World C. "Hello, World!"
B. Hello, World! D. Hello, World
39. What is the correct syntax to print multiple values in Python using the print() function?
A. print("Value1", "Value2") C. print("Value1" "Value2")
B. print("Value1"; "Value2") D. print(Value1 + Value2)
40. Which of the following statements about the print() function is true?
C. The print() function is used to display output on
A. The print() function can only print strings.
the console.
D. The print() function is used to read input from
B. The print() function cannot take multiple parameters.
the user.
41. What is the default data type of the value returned by the input() function in Python?
A. int C. str
B. float D. bool
42. How can you convert the user input to an integer in Python?
A. int.input() C. int(input())
B. input.int() D. input(int())
45. Which function can be used along with input() to ensure the input value is treated as an integer?
A. str() C. bool()
B. float() D. int()
46. How can you ensure that the value entered by the user is treated as a floating-point number in Python?
A. Use float() function with input() C. Use str() function with input()
B. Use int() function with input() D. Use bool() function with input()
47. Which of the following is true about the input() function in Python?
C. It can be used with int() and float() to accept
A. It can only accept string input from the user.
numerical input.
B. It returns the input as an integer by default. D. It cannot be used to accept input from the user.
48. How would you correctly read an integer input from the user and store it in a variable called number?
A. number = input(int("Enter a number: ")) C. number = input("Enter a number: ").int()
B. number = int(input("Enter a number: ")) D. number = int("Enter a number: ")
50. What will be the result of the following expression in Python: 45 - 35?
A. 80 C. -10
B. 10 D. 20
53. How does floor division differ from regular division in Python?
C. It returns the largest integer less than or equal to
A. It returns the decimal part of the division.
the division.
B. It returns the smallest integer greater than the
D. It returns the remainder of the division.
division.
57. Which of the following expressions correctly calculates 2 raised to the power of 3 in Python?
A. 2^3 C. 2^^3
B. 2**3 D. 2*3
63. Which operator is used to check if two values are equal in Python?
A. = C. !=
B. == D. <=
65. Which relational operator checks if the left operand is greater than or equal to the right operand?
A. > C. >=
B. < D. <=
70. Which relational operator is used to check if the left operand is less than the right operand?
A. > C. >=
B. < D. ==
72. Which relational operator will evaluate to True for the expression 5 != 3?
A. == C. >
B. < D. !=
ANSWERS
1.B 2.B 3.C 4.B 5.A 6.B 7.B 8.B 9.C 10.B
11.D 12.A 13.B 14.B 15.C 16.A 17.B 18.B 19.B 20.C
21.C 22.A 23.C 24.B 25.D 26.D 27.B 28.B 29.B 30.D
31.D 32.C 33.C 34.C 35.D 36.B 37.C 38.B 39.A 40.C
41.C 42.C 43.A 44.B 45.D 46.A 47.C 48.B 49.D 50.B
51.C 52.B 53.C 54.D 55.B 56.C 57.B 58.A 59.B 60.C
61.C 62.C 63.B 64.A 65.C 66.A 67.C 68.C 69.B 70.B
71.A 72.D 73.B