반응형
함수 생성
"add_three" 함수 생성
# Define the function
def add_three(input_var):
output_var = input_var + 3
return output_var
함수 사용
# Run the function with 10 as input
new_number = add_three(10)
# Check that the value is 13, as expected
print(new_number)
결과: 13
함수 멀티 파라미터(multiple arguments)
def get_pay_with_more_inputs(num_hours, hourly_wage, tax_bracket):
# Pre-tax pay
pay_pretax = num_hours * hourly_wage
# After-tax pay
pay_aftertax = pay_pretax * (1 - tax_bracket)
return pay_aftertax
higher_pay_aftertax = get_pay_with_more_inputs(40, 24, .22)
print(higher_pay_aftertax)
결과: 748.8000000000001
함수 인자가 없는 경우 (no arguments)
# Define the function with no arguments and with no return
def print_hello():
print("Hello, you!")
print("Good morning!")
# Call the function
print_hello()
결과: Hello, you!
Good morning!
<< 참조 >>
https://www.kaggle.com/code/alexisbcook/functions
Functions
Explore and run machine learning code with Kaggle Notebooks | Using data from No attached data sources
www.kaggle.com
반응형
'프로그램 개발해서 돈벌기 > AI' 카테고리의 다른 글
파이션(python) 초등 완전 기초: 조건문(Conditions and Conditional Statements) (0) | 2023.02.10 |
---|---|
파이션(python) 초등 완전 기초: 데이타 타입(Data Types) (0) | 2023.02.09 |
파이션(python) 초등 완전 기초: 연산과 변수 (0) | 2023.02.07 |
ChatGPT 개념과 사용법(API 샘플 코드 포함) (0) | 2023.02.06 |
CLIP 소개 (0) | 2023.02.02 |
댓글