Python Learning-2 Python starter essentials

Source: Internet
Author: User
Tags python script

1. Python Indent

Is the Python indent a tab or a space? All can, can be a tab, can also be 4 spaces, but most importantly, the entire Python script indentation must be unified, otherwise it will be an error.

2. Code Comment

There are two ways to annotate Python, as follows:

# This is a single-line comment "' This is a multiline comment here is a 3 single quote ~" "" " this is a multiline comment here is a 3 double quotation mark ~" "

3. Sentence break

#!/usr/bin/pythona=2;b=23                #python默认每行一条代码, but you can also separate two statements with a semicolon if a > b:    print (a)            # The indent statement is written after the colon else:p rint (b)                 print (a+b);p rint (' Hello Boy ');    #使用分号将两条语句写在同一行

In Python, there is no difference between single and double quotes, which can be used to enclose strings, and this is the same as JS.

4. Receive input parameters

# !/usr/bin/pythona=input (" Please enter a:") b=input (" Please enter B: " if a > b:    print(a)            # indent statements are written after a colon else:    print(b)

5. A case of mathematical operation

# !/usr/bin/python " " perform mathematical operations subtraction in Python, etc. " " Print (Action) Print # 2 of the 10-time Square Print (3*5/2) Print (3.0*5/2)
Print (99**99) # Python supports large integers

Python Learning-2 Python starter essentials

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.