Files
Man1130/jupyter/Man1130-python-comission/course_materials/Note/a1-4-function.py
louiscklaw e44aead3d5 update,
2025-02-01 01:58:19 +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()