Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- deep learning
- Set Transformer
- Classificaion
- word2vec
- Self-loop attention
- machine learning
- abstraction
- overfitting
- pytorch
- Attention
- sentence embedding
- NLP
- XOR
- neural net
- Transformer
- Python
- elif
- GNN
- sigmoid
- python practice
Archives
- Today
- Total
Research Notes
[Python Practice] Variable, Parameter 본문
< Question 1 >
# name(이름), nationality(국적), phone_number(핸드폰 번호)라는 변수를 만들고, 여러분에게 알맞은 정보들을 지정하세요.
# 변수와 문자열 포맷팅을 이용하여 아래와 같이 출력되게 하세요.
# Hi, my name is XXX. I'm from Korea.
# My phone number is 010-1234-5678.
< Answer 1 >
name = "Veronica"
nationality = "한국"
phone_number = "010-8282-3317"
print("Hi, my name is %s. I'm from %s.\nMy phone number is %s" %(name, nationality, phone_number))
< Explanation 1 >
name, nationality, phone_number에 각각 변수값을 주고
문자열 포맷팅 형식으로 프린트를 한다. 쉬워서 해설이 필요가 X

1번 실행화면
< Question 2 >
# 문자열 first_name(이름)과 문자열 last_name(성)을 파라미터로 받는 함수 print_full_name을 쓰세요.
< Answer 2 >
# print_full_name 함수 정의
def print_full_name(first_name, last_name) :
print(last_name + first_name)
# 테스트 코드
print_full_name("윤수", "이")
print_full_name("수민", "이")
< Explanation 2 >
print_full_name 함수를 정의하고 파라미터값을 지정한다.
파라미터값 함수의 이름 옆 괄호 안에 지정한다.
=> def print_full_name(first_name, last_name) :
이 함수가 프린트할 값을 지정한다.
=> print(last_name + first_name)
print_full_name 함수를 출력한다.
=> print_full_name("이름" , "성")

2번 실행화면
'Programming Language > Python' 카테고리의 다른 글
[Python Practice] Determine even/odd number (0) | 2023.07.03 |
---|---|
[Python Practice] Make Change Calculator using Python (0) | 2023.07.03 |
[Python] Abstraction - Return, Global/Local, Constant Variable (0) | 2023.07.03 |
[Python] Abstraction - Variable, Function (0) | 2023.07.03 |
[Python] Data Type: Boolean, Type Function (0) | 2023.07.03 |