Today we are studying Python's input-output IO and data types.
The input of Python is a function (a built-in function similar to C # 's Readkey ()), such as assigning a value to a variable a, requiring the user to enter an assignment to write A=input (), or to use a a=input if you need to prompt the user for a name and assign a value to a Please enter your name '), but in the process of using a problem, is to let the user enter a number, and processing, such as:
A=input (' Please enter a number ')
If a>100:
Print (a)
Else
Print (a+100)
Result error
Unorderable type:str () int (). Probably say the type does not match, the principle Python gets the input value by default is a string type, so need to convert under, as to how to convert tomorrow to learn.
The second is the escaping problem, say you want to output ' hello,world! ' (including quotes "'), Intuition tells us print (' hello,world! '), but this is not possible because single quotes and double quotes are reserved in Python, have special meanings and cannot be used directly as strings, so we need to turn to the idea (like C # If you want to output ', you must use \ '; double quotation marks the same way \ "and a newline \ n, sky lattice \ t.
Also learned that Python is case-sensitive, this slightly pit dad. And the indentation of what will not be written.
Data type
Python supports all common data type shaping, floating-point numbers (for very long floating-point numbers can be expressed in scientific notation, such as 1.2*10^-10 can be represented as 1.2e-10), 16 binary (denoted by a 0x prefix). ) String type, Boolean (note Case true,false), Boolean type supported or with non-op. Null value None.
And in the case of assignment, A=1, the next second you can write a= ' abc ', is no problem, because Python is a dynamic language, whereas those languages that require a qualified type before declaring a variable are static languages, such as C#,java.
In addition Python is not constant one said.
The//symbol in 10//3 is called the floor in addition to (tease name), that is, the remainder only takes an integer, then the front equals 3, not 3.3333333 ....
Python Learning Diary-i/o&type