Files
004_comission/Man1130/jupyter/Man1130-python-comission/course_materials/Note/a1-4-function.py
louiscklaw fc6f79b133 update,
2025-01-31 20:57:47 +08:00

31 lines
475 B
Python

def say_hello():
print('Hello World!')
def area_of_square(length):
return length**2
def area_of_circle(radius):
pi = 3.1415926
return pi*radius**2
# pi can also be defined outside of the function
# good and bad?
# what if someone change the value outside?
def area_of_rectangle(length,width):
return length*width
def app():
age = int(input('What\'s your age?'))
print('Your age is {}'.format(age))
print('-------')
app()
app()