The first day of python introductory basics "" "Hello World" and the use of if-elif, data types

(1) The first program "" "Hello World"

Implement python environment print output: Hello World

program:

print("Hello World")

data type conversion

Data type: int integer, str character type, data of different types cannot be added or subtracted.

correct:

 

mistake:

 

 

Error message:

Different types of data cannot be added or modified. The input data is saved as str type, so the operation is wrong. It is enough to force the type conversion to int class.

After modification:

(3) Usage of if and elif:

Example:

When writing if and elif statements, the following statements must be indented, otherwise an error will occur: as follows:

In the python language, the tab key is generally used for indentation, and the indentation format of two adjacent output statements must be the same"

E.g:

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325218306&siteId=291194637