-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit solution bài tập Diều kiện If Then Else
- Loading branch information
Hieu Nguyen
committed
Aug 3, 2016
0 parents
commit f392227
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
score = input("Enter your score: ") | ||
score = int(score) | ||
|
||
# Basic solution - nested | ||
if score >= 90: | ||
print('grade is A') | ||
else: | ||
if score >= 80: | ||
print('grade is B') | ||
else: | ||
if score >= 70: | ||
print('grade is C') | ||
else: | ||
if score >= 60: | ||
print('grade is D') | ||
else: | ||
print('grade is F') | ||
|
||
# Advanced solution | ||
if score >= 90: | ||
print('grade is A') | ||
elif score >= 80: | ||
print('grade is B') | ||
elif score >= 70: | ||
print('grade is C') | ||
elif score >= 60: | ||
print('grade is D') | ||
else: | ||
print('grade is F') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Prompt user to input | ||
weight = input("Enter your weight (pounds): ") | ||
height = input("Enter your height (inches): ") | ||
|
||
# Convert user input into float values | ||
weight = float(weight) | ||
height = float (height) | ||
|
||
# Convert weight into kilograms and height into meters | ||
weight = weight * 0.45359237 | ||
height = height * 0.0254 | ||
|
||
# Calculate BMI | ||
bmi = weight / (height * height) | ||
|
||
# Print health status | ||
if bmi < 18.5: | ||
print("Underweight") | ||
elif bmi < 25: | ||
print("Normal") | ||
elif bmi < 30: | ||
print("Overweight") | ||
else: | ||
print("Obese") |