꼬물꼬물 개발자
while 본문
# Python Standard Library 사용법
import random
#from random import randint
# if 함수
pc_choice = random.randint(1, 50)
user_choice = int(input("Choose number."))
if user_choice == pc_choice:
print("You won!")
elif user_choice > pc_choice:
print("Lower! Computer chose", pc_choice)
elif user_choice < pc_choice:
print("Higher! Computer chose", pc_choice)
# while 함수
distance = 0
while distance < 20:
print(f"I'm running {distance} km")
distance = distance + 1
# if함수 -> while 함수
print("Welcome to Python Casino.")
pc_choice = random.randint(1, 100)
playing = True
while playing:
user_choice = int(input("Choose number.(1-100)"))
if user_choice == pc_choice:
print("You won!")
playing = False
elif user_choice > pc_choice:
print("Lower!")
elif user_choice < pc_choice:
print("Higher!")
'Python' 카테고리의 다른 글
list, tuples, dictionary (0) | 2024.08.31 |
---|---|
input, and, or (0) | 2024.08.29 |
if, else, elif (0) | 2024.08.23 |
Return (0) | 2024.08.22 |
Functions (0) | 2024.08.22 |