NeatCoder's Lab

Data types in python 본문

Python/Python Basics

Data types in python

NeatCoder 2020. 7. 18. 10:07

Today we will try to learn about the data types of python. 

  • Text type : str
  • Numeric type : int, float, complex
  • Sequence type : list, tuple, range
  • Mapping type : dict
  • Boolean type : set, frozenset
  • Binary type : bool
  • Set type : bytes, bytearray, memoryview

Variables can store data of different types, and different types are for diferent purposes. Here are some examples below

x = "Hello World"	#str	
x = 20	#int	
x = 20.5	#float	
x = 1j	#complex	
x = ["apple", "banana", "cherry"]	#list	
x = ("apple", "banana", "cherry")	#tuple	
x = range(6)	#range	
x = {"name" : "John", "age" : 36}	#dict	
x = {"apple", "banana", "cherry"}	#set	
x = frozenset({"apple", "banana", "cherry"})	#frozenset	
x = True	#bool	
x = b"Hello"	#bytes	
x = bytearray(5)	#bytearray	
x = memoryview(bytes(5))	#memoryview

 

 

'Python > Python Basics' 카테고리의 다른 글

문자열  (0) 2020.07.19
What is python  (0) 2020.07.18
Comments