본문 바로가기
Python

파이썬 기초 02. 변수와 데이터타입

by Y25N 2023. 9. 18.
728x90

 

'''
단일데이터:
- 기본자료형
int: 소수점이 없는 10진수
float: 소수점이 있는 수
str: 하나 또는 다수의 문자로 구성된 형태. 쌍따옴표 or 홑따옴표
bool: true/false 두 가지 값을 가짐
'''

#변수에 값 할당
name = 'James'
age = 20
height = 175.0
isChild = age<20

print(name, age, height,isChild, sep=',')

print(type(age),type(name),type(height),type(isChild),sep=',')

#키보드로 변수에 값 입력받기 -> input 사용 -> 무조건 문자형으로 입력됨
input()

a = input()
print(type(a))

#자료형 변환하기
#int(value), float(value), str(value)
a = int(input())
b = float(input())
c = str(input())

print(type(a))
print(type(b))
print(type(c))

'Python' 카테고리의 다른 글

파이썬 기초 06. 프로그램의 흐름 제어하기  (0) 2023.09.18
파이썬 기초 05. if문  (0) 2023.09.18
파이썬 기초 04. 문자열  (1) 2023.09.18
파이썬 기초 03. 사칙연산  (0) 2023.09.18
파이썬 기초 01. 파이썬 시작  (0) 2023.09.18