Simple Python Programs Quiz - CBSE Class 9 ICT
Free practice quiz: Simple Python Programs (CBSE Class 9 ICT). 19 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 19 questions freeSample questions
What is the correct output of the following code: print('Hello World')?
- Hello
- Hello World
- Hello World!
- Hello, World!
Show answer
Answer: B. Hello World
The print function outputs the string as it is provided within the quotes. Therefore, the correct output is 'Hello World'.
Which of the following data types is mutable in Python?
- Tuple
- String
- Set
- Integer
Show answer
Answer: C. Set
Among the given data types, a set is mutable, meaning its contents can be changed after it is created.
What is the result of the expression: 10 // 3?
- 3
- 3.33
- 4
- 30
Show answer
Answer: A. 3
The // operator in Python performs floor division, which discards the fractional part and returns the largest integer less than or equal to the division result.
What is the result of the expression: [1, 2, 3] * 2?
- [1, 2, 3, 1, 2, 3]
- [2, 4, 6]
- [1, 2, 3]
- [1, 2, 3, 2]
Show answer
Answer: A. [1, 2, 3, 1, 2, 3]
The * operator when used with lists repeats the list. Thus, [1, 2, 3] * 2 gives [1, 2, 3, 1, 2, 3].
Which of the following constructs can be used to create a function in Python?
- function
- def
- define
- func
Show answer
Answer: B. def
In Python, the 'def' keyword is used to define a function.