Home>Article>Backend Development> Python basics input, output and operators

Python basics input, output and operators

零下一度
零下一度 Original
2017-07-26 09:41:11 3050browse

Today we will summarize the most basic input, output and operators

Input:

python3 There are input ("")

input()

##name = input() #The input value will be directly assigned to name

name = input("Please enter your name:") #("") is the input prompt message

ps:

The entered value will be directly assigned to name.

The input values input are all str type. If you want to input a numeric type value, you can: name = int(input()) The input method for other types is the same.

Output:

Output the name value just now. (With text prompt)

1.print("Name:",name)

2.print("Name: %s" %name) #% represents the placeholder s, that is, the character corresponds to the following %

The second method is recommended because it can control the printing position.

ps:


##Operator:

Arithmetic operator:

Define two variables a = 10 b = 20

Assignment operator:

##Comparison operators:

Logical Operators:


#Little knowledge points:

Python files can have any suffix name. Because it is an interpreted language, its suffix name has nothing to do with the file execution. However, it is recommended that everyone use the .py suffix to facilitate differentiation.

The above is the detailed content of Python basics input, output and operators. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn