list : 배열 같은거
days =["Mon", "Tue", "Wed", "Thur", "Fri"]
tuple : 값을 바꿀 수 없는거
days =("Mon", "Tue", "Wed", "Thur", "Fri")
dictionary : 객체 같은 거
sunny = {
"name": "Sunny",
"age": 26,
"korean": True,
}
print(sunny["age"])
sunny["female"] = True
print(sunny);
def : 함수 같은 거
def say_hello(name="anon"):
print("hello", name)
say_hello() //hello anon
say_hello("sunny") //hello sunny
keyworded Arguments: 그냥 변수 집어넣는거
def say_hello(name, age):
# 앞에 f 붙이는거 잊지 않기
return f"Hello {name} you're {age}"
hello = say_hello("sunny", "26")
print(hello) ## Hello sunny you're 26
조건문
def plus(a, b):
if type(b) is int or type(b) is float:
return a+b
else :
return None
print(plus(12,"10")) ## None
print(plus(12,10.2)) ## 22.2
Boolean Operations - and, or, not
elif: else if 같은 거
and : && 같은거
or: ||같은거
for in 반복문
days =("Mon", "Tue", "Wed", "Thur", "Fri")
for day in days :
print(day)
모듈