🐍 파이썬/파이썬 연습문제

[input/string interpolation] 유저에게 인풋을 받아서 프린트하기

써니(>_<) 2022. 7. 17. 06:58

생각보다 쓰일일이없어서 검색하지않고서는 기억이 안날수있는 문법중에하나인 input function과 헷갈리는 string interpolation !

 

문제 : Ask from the user the following information: name, age, occupation and print the following message using the provided values: Hi NAME! I see you are AGE years old and work as a OCCUPATION.

 

# ask and store what the user has typed in a variable
name = input('What is your name?')
age = input('How old are you?')
occupation = input('What is your occupation?')

# f-string interpolation
print(f'Hi {name}! I see you are {age} years old and work as a {occupation}.')