Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

JINIers

Day 8 def 본문

공부/Python

Day 8 def

JINIers 2024. 6. 17. 10:45

# Function의 기본유형(def)

# funtion의 기본 유형
'''
def my_function():
  여기에 적절한걸 넣으면 됨
'''

# Review: 
# Create a function called greet(). 
# Write 3 print statements inside the function.
# Call the greet() function and run your code.
# Greeting()이라는 함수를 만듭니다.
# 함수 안에 3개의 print 문을 작성합니다.
# Greeting() 함수를 호출하고 코드를 실행합니다.

def greet():
  print("no.1"),
  print("no.2"),
  print("no.3"),
  print("")
greet()


# function wuth inputs
'''
def my_function(something):    # 괄호 안에 변수의 이름 추가
  이것
  저것
  그것
'''

def greet_with_name(name):
  print(f"hi, {name}!")
  print(f"how do you do {name}!")
  print("")

greet_with_name("mingyu")

############################
# function that allow for input
'''
parameter : 전달되는 데이터의 이름
argument : 데이터의 실제 값
'''

# function with more than 1 input
def greet_with(name, location):
  print(f"hello {name}!")
  print(f"what is it like in {location}")
  print("")
greet_with("jun","china")
#         ---------------- <- positional Argument

# keyword arguments
''' def my_function(a=1, b=2, c=3):
  this b
  that c
  else a
print -> this 2, that 3, else 1
'''

greet_with(location= "cadana", name="mingyu")

'공부 > Python' 카테고리의 다른 글

Day 9  (0) 2024.06.19
Day 8 cipher  (1) 2024.06.17
[Python 100 day challenge ] Day 6 - 허들  (1) 2024.04.20
[Python 100 day challenge ] Day 5 - for  (0) 2024.03.27
[Python 100 day challenge ] Day 4  (0) 2024.03.27
Comments