Python learning log for small y--variables

Source: Internet
Author: User

#本文仅为个人学习过程的整理和记录, 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.