likenzhi
2022.02.04
@likenzhi님이 새 포스트를 작성했습니다.
모각코 1일차 - 도형 별 넓이 계산기
import math print(''' ==========도형 목록========== 1. 원 2. 삼각형 3. 직사각형 4. 정사각형 ============================ ''') def circle(r):     return r * r * math.pi def triangle(w, h):     return w * h / 2 def rectangle(w, h):     return w * h def square(w):     return w ** 2 sel = int(input("도형 목록에서 넓이를 계산 할 도형의 번호를 입력해주세요 : ")) if sel == 1:     shape = '원'     ra = int(input(f'{shape}의 반지름 길이를 입력해주세요 : '))     print(f'반지름 길이가 {ra}인 {shape}의 넓이는 약 {circle(ra):0.2f}입니다.') elif sel == 2:     shape = '삼각형'     wid = int(input(f'{shape}의 밑변 길이를 입력해주세요 : '))     hei = int(input(f'{shape}의 높이 길이를 입력해주세요 : '))     print(f'밑변이 {wid}이고 높이가 {hei}인 {shape}의 넓이는 {triangle(wid, hei)}입니다.') elif sel == 3:     shape = '직사각형'     wid = int(input(f'{shape}의 가로 길이를 입력해주세요 : '))     hei = int(input(f'{shape}의 세로 길이를 입력해주세요 : '))     print(f'가로가 {wid}이고 세로가 {hei}인 {shape}의 넓이는 {rectangle(wid, hei)}입니다.') elif sel == 4:     shape = '정사각형'     wid = int(input(f'{shape}의 한 변의 길이를 입력해주세요 : '))     print(f'한 변의 길이가 {wid}인 {shape}의 넓이는 {square(wid)}입니다.') else:     print('보기에 표시되어 있는 번호를 입력해주세요') 제 뇌는 쓰레기인가봐요,,