3-1.
Identifier. Why is variable name and variable type declaration not required in Python?
[Answer] These answers are found online.
In Python, the object type and memory are determined at runtime. When a value is created, the interpreter determines the type of the new object based on the syntax and the right operand.
The variable is automatically declared when it is assigned for the first time. Python is a non-typed language.
Python is both a dynamic type language (because it determines the data type only during running without displaying the data type declaration) and a strong type language (because only one variable obtains a data, it has always been the Data Type of this data ).
3-2.
Identifier. Why does not the function type need to be declared in Python?
[Answer] These answers are found online.
The function does not define the returned data type. Python does not need to specify the Data Type of the returned value, or even whether the returned value exists. In fact, each Python function returns a value. If the function executes the return statement, it returns the specified value; otherwise, it returns None (a null value in Python ).
3-3.
Identifier. Why should we avoid double underscores (_) at the beginning and end of the variable name?
[Answer]
Because the variable name _ xxx _ has a special meaning for Python, this naming style should be avoided for common variables.
3-4.
Statement. Can multiple statements be written in one line in Python?
[Answer]
Yes.
3-5.
Statement. In Python, can a statement be divided into multiple lines for writing?
[Answer]
Yes.
3-6.
Variable assignment.
(A) What values will be assigned to the values x, y, z = 1, 2, and 3 in x, y, and z?
(B) After z, x, y = y, z, x is executed, what values are contained in x, y, and z?
[Answer]
>>> X, y, z = 1, 2, 3
>>> Z, x, y = y, z, x
>>> X, y, z
(3, 1, 2)
>>>
3-7.
Identifier. Which of the following are valid Python identifiers? If not, describe the reason. Which of the following keywords are valid identifiers?
Int32 40XL $ aving $ printf print
_ Print this self _ name _ 0X40L
Bool true big-daddy 2hot2touch type
ThisIsn 'tavar thisavar R_U_Ready Int True
If do counter-1 access-
[Answer]
The string rules of Python identifiers are similar to most other advanced languages written in C:
The first character must be a letter or underscore (_). The remaining characters can be letters, numbers, or underscores (_). It is case sensitive.
Int32, printf, _ print, this, self, _ name _, bool, true, type, thisavar, R_U_Ready, Int, True, do, and access are valid Python identifiers.
Print and if are valid Python identifiers and keywords.
40XL, $ aving $, 0X40L, big-daddy, 2hot2touch, thisn' tAVar, counter-1, and-are not Python's legal identifiers.