Python base variable assignment, if statement

Source: Internet
Author: User

1. Assigning values to variables

Letters are quoted as strings, not labeled as variable names.

" Jbzhang "  = nameprint="jbz"print(name2)

Memory Reclamation: The memory space created, when there is no variable pointing, the memory space will be emptied or deleted directly.

Like what:
1. Delete directly
Age=21
Del age
2. Cancel the point
Age=22
Age=23

2.if Statement Implementation guess age

Age_of_princal= + = Int (input (">>:"))if guess_age = = age_of_princal:     Print ("yes,you got it. " Else:    print("no,it ' s wrong . ")

3. Multi-Branch If statement

score= Int (Input ("Score:"))ifScore > 90:    Print("A")elifScore > 80:    Print("B")elifScore > 70:    Print("C")elifScore > 50:    Print("D")Else:    Print("Roll")

Python base variable assignment, if statement

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.