#내장함수
numbers = [10, 30, 4, 64, 32, 17, 9]
print(min(numbers)) #리스트 안에서 최솟값 찾기
print(max(numbers)) #리스트 안에서 최댓값 찾기
#사용자 정의 함수
def compare(a, b):
if a > b:
print(f"{a}가 더 큽니다.")
else:
print(f"{b}가 더 큽니다.")
#매개변수가 있고 리턴 값이 없는 함수
compare(10, 20)
compare(3, 7)
def my_max(list):
max = 0
for i in range(7):
if list[i] > max:
max = list[i]
return max
#매개변수도 있고 리턴 값도 있는 함수
print(my_max(numbers))
def my_min(list):
min = list[0]
for i in range(7):
if list[i] < min:
min = list[i]
return min
print(my_min(numbers))
To embed this project on your website, copy the following code and paste it into your website's HTML: