Skip to content

Commit

Permalink
Commit solution bài tập Diều kiện If Then Else
Browse files Browse the repository at this point in the history
  • Loading branch information
Hieu Nguyen committed Aug 3, 2016
0 parents commit f392227
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea
29 changes: 29 additions & 0 deletions DieuKienIfThenElse_BaiTap1.py
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')
24 changes: 24 additions & 0 deletions DieuKienIfThenElse_BaiTap2.py
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")

0 comments on commit f392227

Please sign in to comment.