Python3.x based learning - its own popular ways of understanding (b)

Talk about the concept of variables and constants:

Variable name:

Alias memory address: Define
methods: first assignment will be defined, the variable name = data
again will change the assignment of variables to point

Named variables: usually it consists of numbers, letters, underscores, and can not start with a number, not the same name and keywords, try to know the literal meaning

Naming method: a small hump name: userName, user_name

Large hump name: TestCase

Named constants:

All uppercase letters as a constant: PI = 3.14

 

 

Talk about the concept of the type of conversion:

For example, is the int type to float type, the type str into an int, char into an int type

int (x) will be converted to an integer x int (20.44) 
a float (x) converting a floating point number x to a float (10)
STR (x) will be converted to a string object x STR (123)
CHR (x) a integer is converted to a character: CHR (65)
the ord (X) into an integer to a character: the ord ( 'a')
the eval (STR) function is used to perform a string expression, and returns the value of the expression: eval ( "34 + 23")

and some conversion is not enough

a = '1.2'
print(type(a))#<class 'str'>
print(float(a)) #1.2
print(int(a))  # ValueError: invalid literal for int() with base 10: '1.2'

 

Some basic concepts operator:

Arithmetic operators: mathematics is some basic arithmetic operators: +, -, *, /, // (quotient),% (remainder) ** (power)

Assignment operator: is the result of the right to the left, use the "=" sign

Logical operators: and, or, not, priority: not> and> or

Comparison operators:! <,>, <=,> =, ==, = condition is true returns True, otherwise False

 

Guess you like

Origin www.cnblogs.com/johnsonbug/p/12556480.html