Question Detail

COS 102 lecture 4 Objective Question

Question

How does Python's approach to variable declaration differ significantly from languages such as Java or C++?
Options
A Python requires explicit declaration of a variable's data type before assignment.
B Python variables are bound to a specific data type and cannot change.
C Python has no command for declaring a variable; it's created upon assignment.
Correct Answer
D Python only allows variables to store unique data types, unlike C++.
Correct Answer

Option C is the correct answer.

Detailed Explanation

Page 27 and 28 highlight that Python differs from Java, C, or C++ because "Other languages declare and bind a variable to a specific data type." In contrast, "Python has no command for declaring a variable. A variable is created the moment you first assign a value to it."

Hint

Focus on the initial creation process of a variable in Python versus 'other languages'.

Question Info