Python get started the second week, do not forget beginner's mind party always

Source: Internet
Author: User

Read a little every week.  Do not forget to beginner's mind party always! Continue Python second play.

flag="  "             flag2=" Queen "print(flag+ " \ n "+Flag2)               #这里细心的小伙伴可能会发现. Flag has one more space before and after Flag2.  Print(flag+"\ n"+flag2.strip ()) When the front space is printed      Python comes with a function strip () that removes the front and back spaces. Automatically remove the front and back space, also known as delete blank. and Rstrap () remove the trailing blanks, lstrap () remove the opening spaces

The python I installed here is version 3.6. But in the version of Python2. The print statement is not required to take the following () for example

Print(" Queen ")  #3版本 print" queen "    #2版本, a little detail. Since the version after 3. Print () is treated as a function to use

About the arithmetic operations of Python

Subtraction don't say, here's the point to mention the exponentiation operation

Print (3**2)   #python里面对于乘方使用两个 * represented. (3**2) represents 3 of 2 =9print(3**3)

For mixed use of string types and fee string types (int, etc.)

Print (" China first "+19+ " big Meeting held in Beijing ")         #第一句话我们是想输出 "China 19th Congress held in Beijing", But Python has an error. Why, this involves the numeric type and string mix, Python does not know what type of print your 19 represents (" China "+str (19) + " big Meeting held in Beijing ")    #所以我们要用str () function to convert a variable of a non-character type

See you next week!

Python get started the second week, do not forget beginner's mind party always

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.