Chapter-4 Computational Thinking & Programming in Python — Online MCQ Test
INFORMATION TECHNOLOGY · Grade 7 · CBSE(NCERT)
Practice Chapter-4 Computational Thinking & Programming in Python with a free chapter-wise online MCQ test.
This chapter covers: data types - variables - integer - float - string - if-else - for loop - while loop - Python syntax.
AI-generated questions from basic to board-exam level, with instant results and explanations.
Chapter-4 Computational Thinking & Programming in Python — Important Questions & Answers
What is a variable in Python?
- A. A named storage location that holds a value
- B. A mathematical equation
- C. A loop statement
- D. A function definition
Answer: A. A named storage location that holds a value
A variable is a named container that stores data values which can be used and modified throughout a program.
A variable is a named container that stores data values which can be used and modified throughout a program.
Which of the following is an integer data type?
- A. 3.14
- B. -25
- C. "Hello"
- D. 3.0
Answer: B. -25
An integer is a whole number without decimal points; -25 is a valid integer while 3.14 and 3.0 are floats.
An integer is a whole number without decimal points; -25 is a valid integer while 3.14 and 3.0 are floats.
What is the correct syntax to create a variable named age with value 12?
- A. age = 12
- B. 12 = age
- C. age == 12
- D. age := 12
Answer: A. age = 12
In Python, the assignment operator (=) is used with the variable name on the left and value on the right.
In Python, the assignment operator (=) is used with the variable name on the left and value on the right.
Which data type represents decimal numbers?
- A. Integer
- B. Float
- C. String
- D. Boolean
Answer: B. Float
Float data type is used to store decimal or floating-point numbers like 3.14 or 2.5.
Float data type is used to store decimal or floating-point numbers like 3.14 or 2.5.
What will be the output of: x = 5; print(x + 3)?
- A. 53
- B. 8
- C. 5 + 3
- D. Error
Answer: B. 8
The variable x holds value 5, and adding 3 to it gives 8, which is printed.
The variable x holds value 5, and adding 3 to it gives 8, which is printed.
Which statement correctly identifies all primitive data types used in Python?
- A. int, float, string
- B. integer, decimal, text, boolean
- C. int, float, str, bool
- D. number, letter, symbol
Answer: C. int, float, str, bool
The main primitive data types in Python are int (integer), float (decimal), str (string), and bool (boolean).
The main primitive data types in Python are int (integer), float (decimal), str (string), and bool (boolean).
What is the difference between a 'for' loop and a 'while' loop?
- A. For loops are faster than while loops
- B. For loops are used for a set number of iterations; while loops continue until a condition is false
- C. While loops cannot contain variables
- D. For loops can only work with strings
Answer: B. For loops are used for a set number of iterations; while loops continue until a condition is false
For loops iterate a predetermined number of times (often using range), while while loops repeat as long as a condition remains true.
For loops iterate a predetermined number of times (often using range), while while loops repeat as long as a condition remains true.
Consider this code: x = "5" y = 5 print(x == y) What will be the output?
- A. True
- B. False
- C. 5
- D. Error
Answer: B. False
x is a string "5" and y is an integer 5. They are different data types, so they are not equal (False).
x is a string "5" and y is an integer 5. They are different data types, so they are not equal (False).
Considering computational thinking principles, which statement is TRUE about algorithm design?
- A. Algorithms must always use loops
- B. An algorithm is a step-by-step procedure to solve a problem
- C. Algorithms can only be written in Python
- D. All algorithms require conditional statements
Answer: B. An algorithm is a step-by-step procedure to solve a problem
An algorithm is a logical sequence of instructions; while loops and conditionals are tools, not requirements for all algorithms.
An algorithm is a logical sequence of instructions; while loops and conditionals are tools, not requirements for all algorithms.
What is the output of this tricky code? a = "10" b = "20" print(a + b)
- A. 30
- B. "1020"
- C. 1020
- D. Error
Answer: B. "1020"
Both a and b are strings, so + concatenates them resulting in "1020", not numeric addition.
Both a and b are strings, so + concatenates them resulting in "1020", not numeric addition.