for x in range(30):
print(random.choice(["A","B","C"]))
print("A,B,C 중 랜덤 출력 30반복입니다")
import random
import time
while True:
break
print(random.choice(["메롱","롱메"])
break
print("뭐나올까요")
time.sleep(1)
import random
lunch = random.choice(["사과","딸기","메론"])
lunch = "fridge"
print(fridge)
*List와 Dictionary
information={"name":"Dagam Lee","nation":"Republic of Korea","hobby":"Learning"}
print(information)
print(information.get("hobby"))
information={"specialty":"piano","address":"seoul"}
print(information.get("specialty"))
print(information.get("address"))
information={"born":"seoul","hobby":"movie","favoritefood":"noodle"}
information["specialty"]="piano"
information["address"]="bundang"
del information["favoritefood"]
print(inforamtion)
foods=["된장찌개","제육볶음","김밥"]
print(foods)
del foods[1]
foods.append("돈까스")
대괄호 안에 숫자 넣기 ex) [1]
0, 1, 2
-3,-2,-1 음수는 0이 없게 꺼꾸로 카운트
끝까지 반복하기
for x in range(30):
print(x)
foods=["된장찌개","피자","제육볶음"]
for x in range(3);
print(foods[x])
for x in range foods:
print(x)
information ={"born":"seoul","hobby":movie","favoritefood":"noodle"}
for x, y in information.items():
print(x)
print(y)
foods=["된장찌개","피자","제육볶음","된장찌개"]
foods_set1 = set(foods)
print(foods)
print(foods_set)
menu1 = set(["된장찌개","피자","제육볶음"])
menu2 = set(["된장찌개","떡국","김밥"])
menu3 = menu1|menu2 // 합집합
menu3 = menu1&menu2 // 교집합
menu3 = menu1-menu2 // 차집합
print(menu3)
if (food =="제육볶음"):
print("곱배기 주세요")
else:
print("그냥 주세요")
print("종료")
print(lunch)
차집합, 변수 (delete item by deference of sets)
set_lunch = set(["된장찌개","피자","제육","짜장면"])
item = "짜장면"
print(set_lunch-set([item]))
set_lunch=set_lunch-set([item])
print(set_lunch)
메뉴 코딩 종합
import random
import time
lunch =["된장찌개","짬뽕","짜장"]
while True:
print(lunch)
item = input("음식을 추가해 주세요 : ")
if(item == "q")
break
else:
lunch.append(item)
print(lunch)
set_lunch=set(lunch)
while True:
print(set_lunch)
item = input("음식을 삭제해주세요 :")
if(item == "q"):
break
else:
set_lunch = set_lunch - set([item])
print(set_lunch,"중에서 선택합니다.")
print("5")
time.sleep(1)
print("4")
time.sleep(1)
print("3")
time.sleep(1)
print("2")
time.sleep(1)
print("1")
time.sleep(1)
print(random.choice( list(set_lunch)))
돌체 라떼 만들기
def make_dolcelatte():
print("1.")
print("2.")
print("3.")
print("4.")
def make_blueberry_smoothie():
print("1.")
print("2.")
print("3.")
print("4.")
def make_siple_latte():
print("1.")
print("2.")
print("3.")
make_dolcelatte()
make_simple_latte()
make_blueberry_smoothie()
while True:
question = input("질문을 입력해 주세요 :")
if question == "q":
break
else:
total_dictionary[question]=""
for i in total_dictionary:
print(i)
answer = input("답변을 입력해 주세요:")
total_dictionary[i] = answer
print(total_dictionary)
for i in total_list:
print(i["질문"])
answer = input("답변을 입력해 주세요 :")
i["답변"] = answer
print(total_list)
season = input("계절을 입력하세요:")
while True:
if(season == "봄"):
print("가디건")
elif(season == "여름"):
print("반팔")
elif(season == "가을"):
print("코트")
elif(season == "겨울"):
print("패딩")
else:
print("잘못 입력하였습니다.")