Python Basics 2

Source: Internet
Author: User

Input output and operator

In Python all is input ("")

name = input () #输入的值会直接赋值给name

Name = input ("Please enter your name:") # ("") in the words to enter the prompt message

Here's how:

Input:

Python3 is all input ("")

Input ()

name = input () #输入的值会直接赋值给name

Name = input ("Please enter your name:") # ("") in the words to enter the prompt message

Ps:

The value you enter is assigned directly to name.

Input value is str type if you want to enter a value of a numeric type, you can: name = Int (input ()) Other types of input methods are identical.

Output:

Output the name value just now. (with text hint)

1. Print ("Name:", name)

2. Print ("Name:%s"%name) #% represents the placeholder s that is the character corresponding to the% following

A second way is recommended because you can control where the print is located.

Ps:

Operator:

Arithmetic operators:

Define two variables A = ten B = 20

Assignment operators:

comparison operators:

logical operators:

Small Knowledge Points:

A python file can be any suffix name because it is an explanatory language, so its suffix is independent of the file run. But it is recommended that everyone use the. py suffix. This also facilitates differentiation.

Python Basics 2

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.