Question Detail

COS 102 lecture 4 Objective Question

Question

How does Python's handling of variables differ significantly from languages like Java, C, or C++?
Options
A Python requires explicit variable declaration with a specific data type.
B Python allows variables to change their type after being set.
Correct Answer
C Python variables can only store integer types by default.
D Python uses a static type system for variables.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 28 explains that in Python, 'Variables do not need to be declared with any particular type and can even change type after they have been set,' which contrasts with languages that bind variables to specific data types upon declaration (page 27).

Hint

Read the 'NOTE' section on page 27 and 'Creating Variables' on page 28, which highlight Python's flexibility compared to other languages.

Question Info