Home>Article>Backend Development> Python basics input, output and operators
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 messageps:
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:
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!