0% found this document useful (0 votes)
8 views3 pages

Basic Python MCQs

Uploaded by

samarthgoyal17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Basic Python MCQs

Uploaded by

samarthgoyal17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DELHI PUBLIC SCHOOL, SECTOR 45, GURGAON

SUBJECT: ARTIFICIAL INTELLIGENCE


CLASS: IX (2025-26)
Basic Python Programming
Multiple Choice Questions

1. Which of the following is a valid variable name in Python?


a) 2nd_number
b) number@one
c) first_number
d) class

2. What will be the output of the following code?


x=5
y=3
print(x + y)

a) 8
b) 53
c) Error
d) None

3. What does the input() function do in Python?


a) Displays output
b) Reads a line from a file
c) Takes user input as a string
d) Terminates the program

4. Which of the following is used to display output in Python?


a) output()
b) echo()
c) display()
d) print()

5. What is the result of this code?


x = 10
x += 5
print(x)

a) 5
b) 10
c) 15
d) 105
6. What does the following code output?
x = 20
x -= 3
print(x)
a) 17
b) 23
c) -17
d) Error

7. Which of the following is a logical operator in Python?

a) +=
b) //
c) and
d) not_equal

8. What will be the value of result in the code below?


x=5
y = 10
result = x < y and y > 5
a) True
b) False
c) 15
d) Error

9. Which of the following lines is a valid comment in Python?


a) /* This is a comment */
b) -- This is a comment
c) // This is a comment
d) # This is a comment

10. What is the purpose of indentation in Python?


a) It is used to declare variables
b) It separates functions
c) It indicates code blocks
d) It decorates the code

11. Which of the following will cause a syntax error?


a) x = 10
b) y = x + 5
c) 5x = 10
d) name = "Alex"

12. Which assignment operator is used to subtract and assign the value in one step?
a) =-
b) -=
c) :=
d) !=
13. What will the following code output?
x = "5"
y = input("Enter a number: ")
print(x + y)
Assume the user enters 3.

a) 8
b) 53
c) Error
d) 5 + 3

14. What type of value does the input() function return?


a) Integer
b) Float
c) String
d) Boolean

You might also like