1. Data type
(1) What is a data type?
Variable values are the data we store, so data types are different types of variable values
(2) why the classification type ?
The value of the variable is to preserve the state of the real world, and it should be expressed in different types for different states.
(3) How to use? What are the types?
integer int access age, mobile number
Float Float- height, weight, salary
(4), String type str
A state, such as a name or address, that describes a property.
Defined:
in single quotation marks, double quotes, three quotes containing a series of characters (three quotes can write multiple lines)
name = ' QQC '
How to use it?
string types can only be : + or *
(5), list type
Function: Used to access multiple values
Definition: Separate multiple values of any type with commas in ""
How to use it?
(6) dictionary dict
function: Used to access multiple values, according to the Key:value to store the value, the time can be obtained by key rather than index to the value,key to Value is a descriptive function;
How to define: {} separate multiple elements with commas, no element is key:value format, where Value can be any type,key Most are string types
(7), Boolean type bool
The condition used for making judgments
definitions:ture and false
2. Formatted output
%s string placeholder (can receive a value of any data type) %d digit placeholder (can only receive shaping
Name = input (' Name: ')
age = Int (input (' Age: '))
Sex = input (' Sex: ')
Job = input (' job: ')
info = ""
%s Info of%s-------
Name:%s
Age:%s
Sex:%s
Job:%s
-----------End--------------
'% ('-' age,sex,job, name, name, ')
Print (info)
3. Basic Operators
A = b -=10 chain Assignment
A = 100
b = 200
A, B = b,a #交叉赋值
Print (A, B)
Python data types and basic operators