실습 1

import random

list=[random.randint(1,100) for _ in range(10)]
print(list)

while True:

    n1=int(input())
    n2=int(input())

    if n1 in list and n2 in list:
        print("예약이 불가합니다")

    

    elif n1 in list or n2 in list:
        if n1 in list:
            print("%d번 좌석을 바꿔주세요" %n1)
        else:
            print("%d번 좌석을 바꿔주세요" %n2)

    else:
        print("예약이 되었습니다")
        break

실습 2

# 사용자로부터 입력 받기
amount = float(input("저축할 금액을 입력하세요: "))
method = input("저축 방식을 선택하세요 (적금/예금): ")
period = int(input("저축 기간을 연단위로 입력하세요: "))

def calculate_savings(amount, period):
    # 단리와 복리를 계산할 초기값 설정
    simple_interest = amount
    compound_interest = amount

    # 단리 계산
    for _ in range(period):
        simple_interest += amount * 0.0299

    # 복리 계산
    for _ in range(period):
        compound_interest *= (1 + 0.0278)

    # 더 나은 방식을 추천
    if simple_interest < compound_interest:
        print("복리로 저축하는 것이 더 유리합니다.")
        print(f"만기 시 약 {compound_interest:.2f} 원을 받을 수 있습니다.")
    else:
        print("단리로 저축하는 것이 더 유리합니다.")
        print(f"만기 시 약 {simple_interest:.2f} 원을 받을 수 있습니다.")

# 함수 호출
calculate_savings(amount, period)

이론1

O

X

O

이론2

o

x

x