#本文仅为个人学习过程的整理和记录, if there is a blog from others, the site extracts the content, I will clearly mark, if there is infringement, please contact me, I will be deleted in the first time.
Two. Python variables
(1) Definition of variables
Variable can store a specified range of values in a chunk of data in the computer's memory, and the value can be changed.
(2) Naming of variables
Variable names have letters, numbers, underscores
Number cannot start
You cannot use a keyword as a variable name
Chestnut: A A1 A_ a_1
(3) Assigning values to variables
Is the process of declaring and defining variables
A=1
ID (a)
Three. Operators and expressions
(1) Python operators include:
Assignment operators
' = ' equals: a=3,b= ' asdfgh '
' + = ' plus equals: a+=3
'-= ' minus equals: a-=3
' *= ' multiplied equals: a*=3
'/= ' except equals: a/=3
'%= ' to seek remainder equals: a%=3
Arithmetic operators
' + ' addition: a+b
'-' subtraction: A-B
' * ' Multiplication: a*b
'/' Real Division: 3/2 (different from 2.x version) 3.1/2
'//' integer division: 5.6/2 5.6//2
'% ' seeking remainder: 17%6=5
' * * ' power operation: 2**3=8
Relational operators
' < ' less than: 1<2
' > ' Greater than: 2>3
' <= ' less than equals: 2<=3
' >= ' greater than equals: ' 3>=2
'! = ' is not equal to: 1!=2
' = = ' is exactly equal to: 2==2
logical operators
' and ' logic with: True and False
' or ' logic or: True or False
' Not ' logical non: not True
Precedence of the operator:
(2) Expression:
An expression is a formula that connects different data (including variables, functions) to certain rules with operational symbols.
(3) Practice
Arithmetic device
#Arithmetic
Import Sys
Running=true
While running:
Try
T=int (input ())
P=int (input ())
Except Eoferror: #EOFError是什么?
Break
Print (' \ n ', t+p)
Print (' \ n ', t-p)
Print (' \ n ', t*p)
Print (' \ n ', t/p)
Python learning log for small y--variables