본문 바로가기

프로그래밍 언어/Python

[Hackerrank] 16. What's Your Name?

16. What's Your Name?

[ 난이도: Easy | 분야: Strings ]

1. 과제

과제 설명

다른 두 줄에 사람에 대한 성씨와 이름이 있다. 이번 과제에서는 이 정보들을 읽고 아래처럼 출력하는 것이다:

Hello firstname lastname! You just delved into python.

 

함수 설명

print_full_name 함수를 완성하라.

print_full_name은 아래 파라미터를 가진다:

- string first: 이름

- string last: 성씨

 

출력할 것

- 문자열: 'Hello firstname lastname! You just delved into python' 양식에서 firstname에는 string first를 lastname에는 string last를 넣어라.

 

입력 양식

첫 번째 줄은 이름을 가지고 있고 두 번째 줄은 성씨를 가지고 있다.

 

제약 사항

각 이름과 성씨의 길이는 10보다 작다.

 

입력 예시0

Ross
Taylor

 

출력 예시0

Hello Ross Taylor! You just delved into python.

 

설명0

프로그램에 의해 읽힌 데이터는 문자열로 저장된다. 문자열은 단어들의 집합이다.

 

문제

#
# Complete the 'print_full_name' function below.
#
# The function is expected to return a STRING.
# The function accepts following parameters:
#  1. STRING first
#  2. STRING last
#

def print_full_name(first, last):
    # Write your code here

if __name__ == '__main__':
    first_name = input()
    last_name = input()
    print_full_name(first_name, last_name)
더보기

정답

def print_full_name(first, last):
    # Write your code here
    result = "Hello " + first +" "+ last +"! You just delved into python."
    print(result)

if __name__ == '__main__':
    first_name = input()
    last_name = input()
    print_full_name(first_name, last_name)

 

 

 

 

 

©️Hackerrank. All Rights Reserved.

'프로그래밍 언어 > Python' 카테고리의 다른 글

[Hackerrank] 18. Find a String  (0) 2024.03.08
[Hackerrank] 17. Mutations  (0) 2024.03.08
[Hackerrank] 15. String Split and Join  (0) 2024.03.07
[Hackerrank] 14. sWAP cASE  (0) 2024.03.06
[Hackerrank] 13. Tuples  (0) 2024.03.06