def calculator(n1, n2, operator):
def addcal():
print(f'덧셈: {n1 + n2}')
def subcal():
print(f'뺄셈: {n1 - n2}')
def mulcal():
print(f'곱셈: {n1 * n2}')
def divcal():
print(f'나눗셈: {n1 / n2}')
if operator == 1:
addcal()
elif operator == 2:
subcal()
elif operator == 3:
mulcal()
elif operator == 4:
divcal()
while True:
userNo1 = float(input('숫자 n1 입력: '))
userNo2 = float(input('숫자 n2 입력: '))
userOption = int(input('1.덧셈 2.뺄셈 3.곱셈 4.나눗셈 5.종료 \t'))
if userOption == 5:
print('BYE')
break
calculator(userNo1, userNo2, userOption)
💔
getTriangleArea = lambda n1, n2: n1 * n2 / 2
getSquareArea = lambda n1, n2: n1 * n2
getCircleArea = lambda r: r * r * 3.14
width = int(input('가로 길이: '))
height = int(input('세로 길이: '))
radius = int(input('반지름 길이: '))
triangleValue = getTriangleArea(width, height)
squareValue = getSquareArea(width, height)
circleValue = getCircleArea(radius)
print('삼각형 넓이: {}'.format(triangleValue))
print('사각형 넓이: {}'.format(squareValue))
print('원 넓이: {}'.format(circleValue))
🤍
import random
rNum = random.randint(1,10)
print(f'rNum: {rNum}')
rNums = random.sample(range(0,101), 10)
print(f'rNums: {rNums}')
💙
import random
rNums = random.sample(range(1,46), 6)
print(f'이번주 로또 번호: {rNums}')
import lotto
def getlottoNum():
rNums = random.sample(range(1,46), 6)
return rNums
import lotto
result = lotto.getlottoNum()
print(f'이번주 로또 번호: {result}')
💔
def reverseStr(str):
reversedStr = ''
for c in str:
reversedStr = c + reversedStr
return reversedStr
---
import reverseStr
userInput = input('문자열 입력: ')
result = reverseStr.reverseStr(userInput)
print(result)
💔