forked from dremdeveloper/codingtest_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable_type.py
More file actions
34 lines (28 loc) · 1.77 KB
/
Copy pathvariable_type.py
File metadata and controls
34 lines (28 loc) · 1.77 KB
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
31
32
33
34
#############################################################
# | cafe | http://cafe.naver.com/dremdelover |
# | Q&A | https://open.kakao.com/o/gX0WnTCf |
# | business | ultrasuperrok@gmail.com |
#############################################################
# 파이썬에서는 여러가지 데이터 타입이 있으며, 각 타입은 서로 다른 종류의 데이터를 저장합니다. 여기서는 주요 변수 타입들을 살펴보겠습니다.
# 1. 정수(Integer): 정수는 양수, 음수 및 0을 포함한 숫자를 나타냅니다.
# 파이썬에서 정수형 변수를 선언할 때는 아래와 같이 합니다.
age = 25
print(age) # 출력: 25
print(type(age)) # 출력: <class 'int'>
# 2. 부동소수점(Floating point): 부동소수점은 소수점이 있는 숫자를 나타냅니다.
# 파이썬에서 부동소수점 변수를 선언할 때는 아래와 같이 합니다.
height = 5.9
print(height) # 출력: 5.9
print(type(height)) # 출력: <class 'float'>
# 3. 문자열(String): 문자열은 한 개 이상의 문자를 나타냅니다.
# 파이썬에서 문자열 변수를 선언할 때는 아래와 같이 합니다.
name = "John"
print(name) # 출력: John
print(type(name)) # 출력: <class 'str'>
# 4. 불리언(Boolean): 불리언은 참(True) 또는 거짓(False) 두 가지 값 중 하나를 나타냅니다.
# 파이썬에서 불리언 변수를 선언할 때는 아래와 같이 합니다.
is_student = True
print(is_student) # 출력: True
print(type(is_student)) # 출력: <class 'bool'>
# 이렇게 서로 다른 타입의 변수들을 선언하고 사용할 수 있습니다.
# `type` 함수는 변수의 타입을 확인하는 데 사용됩니다.