Definition, use and output of variables in python
This article introduces the "definition, use and output of variables in python" related knowledge, in the actual case operation process, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!
1. Define variable
Enter:
# Filename: var.py
I = 5
Print (I)
I = I + 1
Print (I)
S =''This is a multi-line string. This is the second line.'''
Print (s)
Output:
five
six
This is a multi-line string.
This is the second line.
Explanation:
It is preceded by the name of the variable, the code name of a number or a paragraph of characters.
Assignment assigns the latter to the preceding variable through the "=".
(order before and after)
two。 Abbreviation of variable operation
Enter:
A = 2; a * = 3
A = 2; a = a * 3
Output:
six
six
Explanation:
A shorthand method when the same variable appears on both sides of the equal sign.
A=a+3 is equivalent to axiomatic 3.
3. Variable operation output
Enter:
#! / usr/bin/python # Filename: expression.py
Length = 5
Breadth = 2
Area = length * breadth
Print ('Area is', area)
Print ('Perimeter is', 2 * (length + breadth))
Output:
Area is 10
Perimeter is 14
Explanation:
Assign the value first, and then calculate it.
This is the end of the definition, use and output of variables in python. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!