if문 까지 공부

This commit is contained in:
김민구
2021-04-26 20:40:14 +09:00
parent 30ef4cfbc7
commit 21d7d85b67
12 changed files with 420 additions and 3 deletions

22
3. Type_conversion.py Normal file
View File

@@ -0,0 +1,22 @@
# 형 변환(Type Conversion or Type Casting라 함)
# 소수(float)를 정수(integer)로 변환
print(int(3.8))
# 정수를 소수로 변환
print(float(3))
# 문자를 정수로 변환
print(int("2") + int("5"))
# 문자를 소수로 변환
print(float("1.1") + float("2.5"))
# 숫자를 문자로 변환
print(str(2) + str(5))
# 문자열에 정수 넣어 출력
age = 7
print("제 나이는 " + str(age) +"살입니다.")
print("제 나이는 {}살입니다.".format(age))