MINERVA/Python 2021. 9. 7. 11:10
반응형

##################################
# id(x): 객체(x) 주소(address) 확인
##################################
name = 'Python'
print(f'My name is {name} and object id is {id(name)}')

# passed by Assignment!!!(추후 정리)
obj_copy = name # passed by Assignment(o) call by reference(x) call by value(x)
print(f'My name is {obj_copy} and obj_copy id is {id(obj_copy)}')

#################################################
# type(x): 객체(x) 타입(type) 확인
# immutable objects: int, float, string, tuple
# mutable objects: list, dict, set
#################################################
age = 18
colors = ('red','blue','yellow')
print(f'type is {type(name)}')
print(f'type is {type(age)}')
print(f'type is {type(colors)}')

########################################################
# len(x): x 길이(문자열) 또는 원소의 갯수(tuple,list, dic...
########################################################
print(len(name),len(colors))

##################################
# eval(x): (x) 결과를 반환
##################################
a = eval ('"hello" + "python"')
b = eval ('100+40')
c = eval ('len(colors)')
print(f'results are {a}, {b},{c}')

반응형
posted by choiwonwoo
: