Python Basic Learning Notes (i)

Source: Internet
Author: User

Print Statement Learning

The print statement after Python 3 needs parentheses, without error:

1. Print the string:

A single quotation mark or double quotation mark is required to refer to the string, either single or double quotation marks, but to appear in pairs, and the parentheses to appear in pairs, otherwise the statement cannot be terminated:

>>> print ("I love Python")

>>> print (' I love Python ')

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/88/51/wKioL1fvRCyzb8DrAACrJD2Zdoc676.png-wh_500x0-wm_3 -wmp_4-s_1807197863.png "title=" Print.png "alt=" Wkiol1fvrcyzb8draacrjd2zdoc676.png-wh_50 "/>

2, calculate the value:

>>> print (3+5) # # # numerical calculation

8

>>> 3+5 # # # can also be written, directly even if the results

8

>>> print (4*6) # # # Here is the calculation of integers

24

>>> print ("4*6") # # # Here is a string, because double quotes are added

4*6


3. Add the string:

>>> print ("I love Python" + "does you?")

I Love Pythondo?

>>> print ("I love Python" + "does you?") # # Show a space between two words

I Love Python does you?

>>> print ("I love python," + "does you?") # # Add a comma and a space between two words

I Love Python, does you?


4, string and numeric multiplication:

>>> print ("I Love Python" * 3)

I love python i love python i love python

>>> print ("I Love python\n" * 3)

I Love Python

I Love Python

I Love Python


Tip: (1) using the ALT+P key will return the last command statement executed, Alt+n will display the next command statement, that is, return to the command executed by the first command!

(2) \ n = carriage return for line break

This article is from the "Davidlee's Linux Road" blog, so be sure to keep this source http://davidlinux.blog.51cto.com/5965954/1858276

Python Basic Learning Notes (i)

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.