본문 바로가기

부스트캠프 AI Tech/Python

Function and Formatting

Function

def 함수 이름(parameter #1, ... ):
    수행문 #1(statement)
    수행문 #2(statement)
    return <반환값>
  • parameter, argument

    Formatting

  • %-format : "%datatype"%(variable)

    print("I eat %d apples. " % 3)
  • str.format() : "{datatype}".format(argument)

    print("My name is {0} and {1} years old.".format(name,age))
  • fstring : f"{var name}"

    print(f"hello, {name}. You are {age}.")

'부스트캠프 AI Tech > Python' 카테고리의 다른 글

Pythonic code  (0) 2022.01.19
Data Structure  (0) 2022.01.19
String  (0) 2022.01.19
Conditionals and loops  (0) 2022.01.18
Variable & Memory  (0) 2022.01.18