언어/Python

언어/Python

조건문 예제 연습

## Love Calculator # UPDATE We've moved away from repl.it for coding exercises. Check out the new exercises on Coding Rooms with automated submissions. Login to your Udemy course and head over to the link below to get the sign up link: [Click here](https://www.udemy.com/course/100-days-of-code/learn/lecture/17825914#questions) # 💪 This is a Difficult Challenge 💪 # Instructions You are going to w..

언어/Python

다중조건문 예제 2

피자주문 # Instructions Congratulations, you've got a job at Python Pizza. Your first job is to build an automatic pizza order program. Based on a user's order, work out their final bill. ``` Small Pizza: $15 ``` ``` Medium Pizza: $20 ``` ``` Large Pizza: $25 ``` ``` Pepperoni for Small Pizza: +$2 ``` ``` Pepperoni for Medium or Large Pizza: +$3 ``` ``` Extra cheese for any size pizza: + $1 ``` # Ex..

언어/Python

다중 조건문 예제

print("Welcome to the rollercoaster!") height = int(input("What is your height in cm? ")) bill = 0 if height > 120: print("You can ride the rollercoaster!") age =int(input("What is your age? ")) if age < 12: bill = 5 print("Child tickets are $5.") elif age

언어/Python

Multiple if

1) if/ elif/ else if condition1: do A elif condition2: do B else: do C A B C 중 하나만 수행됨 2) Multiple if if condition1: do A if condition2: do B if condition3: do C 모든 조건이 참이라면 A B C 모두 실행됨 들여쓰기의 위치에 주의

언어/Python

조건문 예제 leap year 계산

* 순서도를 그려놓고 생각해보는 것이 좋다 *윤년을 계산하는 문제이므로 윤년이 되는 조건에 따라 다이어그램을 작성 (선행행동) 초기코드 # 🚨 Don't change the code below 👇 year = int(input("Which year do you want to check? ")) # 🚨 Don't change the code above 👆 #Write your code below this line 👇 # 4로 나눴을 때 나머지가 없으면 윤년이다 # 다만 예외로 100으로 나눠지면 윤년이 아니다. # 400으로 나눠지면 윤년이다. # 밑에 두 조건 중 하나만 참이면 윤년인 것 같음 if year % 4 == 0: if year % 400 == 0: if year % 100 == 0: prin..

언어/Python

조건문 예제 bmi 계산

# 🚨 Don't change the code below 👇 height = float(input("enter your height in m: ")) weight = float(input("enter your weight in kg: ")) # 🚨 Don't change the code above 👆 #Write your code below this line 👇 bmi = round(weight/height**2) if bmi < 18.5: print(f"Your BMI is {bmi} , you are underweight. ") elif bmi

언어/Python

if / elif / else

# if / elif / else if condition1: do A elif condition2: do B else: do this age =int(input("What is your age? ")) if age < 12: print("Please pay $5.") elif age 18: print("Please pay $12.") else: print("Sorry, you have to grow taller before you can ride.")

언어/Python

조건문 예제 1

예제 풀이 사전 정보 (홀짝찾기) ## Odd or Even # UPDATE We've moved away from repl.it for coding exercises. Check out the new exercises on Coding Rooms with automated submissions. Login to your Udemy course and head over to the link below to get the sign up link: [Click here](https://www.udemy.com/course/100-days-of-code/learn/lecture/17825914#questions) # Instructions Write a program that works out whether ..

언어/Python

condition - 2(기본)

print("Welcome to the rollercoaster!") height = int(input("What is your height in cm? ")) if height > 120: print("You can ride the rollercoaster!") else: print("Sorry, you have to grow taller before you can ride.") * 각 조건 결과 확인 Welcome to the rollercoaster! What is your height in cm? 130 You can ride the rollercoaster! Welcome to the rollercoaster! What is your height in cm? 110 Sorry, you have ..

우주필링마카롱
'언어/Python' 카테고리의 글 목록