Basic Python Learning 1

Source: Internet
Author: User


One. Python First program

Print ("Hello World")

Two. naming rules for variables

1. Alphanumeric Underline composition
2. Cannot start with a number, cannot contain special characters and spaces
3. Cannot be named with a reserved word
4. Cannot be named in Chinese
5. The variable name defined should make sense
6. Hump-Type life, underline word segmentation
7. Variable names are case-sensitive

Three. If condition judgment

If  a<b:    print ("Yes") Else:    print ("No")

  

If a>b:    print ("A>b") elif a==b:    print ("a=b")     else:    print ("A<b")

Python does not use curly braces and needs to be indented.

Four. Annotation methods

# single-line comment ' multiline comment ' ' "" "Multiline Comment" "

Five. Python's input

Input ("Please enter:")

Six. Python's output

Print ("abc" + "Def")

Concatenation of strings using "+", int type and string type can not be spliced, you need to force type conversion.

Seven. Select the maximum value of the program

Num1=int (Input ("NUM1:")) Num2=int (Input ("num2:")) Num3=int (Input ("num3:")) max_num=0if num1>num2:    max_num= Num1else:    max_num=num2if num3>max_num:    max_num=num3print ("Maximum value:" Max_num)

  

Basic Python Learning 1

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.