Conditional expressions, operators for Python basics

Source: Internet
Author: User
Tags integer division

1. Conditional Expressions:

If.. Elif...else

2. Operators

A+=b #等效a =a+b, add

A-=b #等效a =a-b, subtraction

A*=b #等效a =a*b, multiply
A/=b #等效a =a/b, divide
A%=b #等效a =a%b, take the mold
A**=b #等效a =a**b, Power assignment operation
A//=b #等效a =a//b, take the integer division assignment operation

he.py

#Coding=utf8#Logical ExpressionsdefShow1 (): Age=19ifage<0:Print("Unknown")    elif(age>0 andAge<=18):        Print("Minors")    Else:        Print("has grown")#operatordefShow2 (): a=4b=3a+=b#equivalent a=a+b, added    Print(str (a)) a-=b#equivalent a=a-b, subtraction    Print(str (a)) a*=b#equivalent a=a*b, multiplied    Print(str (a)) a/=b#equivalent a=a/b, dividing    Print(str (a)) a%=b#equivalent a=a%b, modulo    Print(str (a)) a**=b#equivalent a=a**b, power assignment Operation    Print(str (a)) a=b#equivalent a=a//b, divisible assignment Operation    Print(str (a)) STRs=[7,4,60]    #Check if this value exists    if(AinchSTRs):Print("This value exists")    Else:        Print("This value does not exist")

Calling code:

Python 3.6.1 (V3.6.1:69C0DB5, Mar, 17:54:52) [MSC v.1900"copyright"  credits"or"license ()" for more Information.  from import *>>> show1 () adult >>> show2 ()74124.01.01.00.0 This value does not exist 

Conditional expressions, operators for Python basics

Related Article

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.