728x90
반응형
if 문
냉장고에서 사과 찾기 1 (shell에서 실행하기)
fridge=["apple","pear","mandarine","banana"]
where=fridge.index('apple') #index
where
apple=fridge.pop(where) #pop
apple

냉장고에서 사과 찾기 2 (shell에서 실행하기)
fridge=["apple","pear","mandarine","banana"]
if 'apple' in fridge:
where=fridge.index('apple')
apple=fridge.pop(where)
'eat'+apple

BMI 계산기
height=float(input('Enter your height in centimeters:'))
weight=float(input('Enter your weight in kg:'))
height/=100
BMI=weight/(height**2)
print(f'Your Body Mass Index is: {BMI}')
if BMI>0:
if BMI<=16:
print('You are serverely underweight')
elif BMI<=18.5:
print('You are underweight')
elif BMI<=25:
print('You are healthy')
elif BMI<=30:
print('You are overweight')
else:
print('You are serverely overweight')
else:
print('Enter valid details')

728x90
반응형
'즐거운프로그래밍' 카테고리의 다른 글
[파이썬] 기초 다지기 리스트(list), 임의 문자열 생성 (0) | 2023.10.27 |
---|---|
[파이썬] 기초 다지기 while 문 (0) | 2023.10.27 |
[파이썬] 기초 다지기 예제 3 (0) | 2023.10.27 |
[파이썬] 기초 다지기 예제 2 (0) | 2023.10.27 |
[파이썬] turtle을 활용하여 피젯스피너 만들기 (1) | 2023.10.26 |