Don't talk nonsense, just start! ! !
def fun():
a =10
print(a)
fun()
Output result:
def is to define a new function (I defined fun()), and then type fun() at the end, otherwise the output result is 0, or type fun() on the output result.
def fun():
a =10
print(a)
return a + 100
print(fun())
Output result: the
first output is the value of a, and the second output is the value within the function (from def to return).
Note: The variable (a) in the defined function is a local variable and cannot be output directly in subsequent processes. Local variables will be introduced later.