-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday3.py
More file actions
66 lines (66 loc) · 1.83 KB
/
day3.py
File metadata and controls
66 lines (66 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Day3 - Conditional Logic
# Classwork — If Statements
# Question 1 — Positive, Negative or Zero
num=float(input("Enter a number:"))
if num>0:
print("This is a positive number")
elif num==0:
print("This is zero")
else:
print("This is a negative number")
# Question 2 — Voting Eligibility
name=input("What is your name? ")
age=int(input("How old are you? "))
if age>=18:
print(f"{name} you are eligible to vote")
else:
print(f"{name} you cannot vote yet, come back in {18-age} years!")
# Question 3 — Grade Calculator
score=float(input("What is your score?"))
if score>=90:
print("Your grade is A")
elif score>=80:
print("Your grade is B")
elif score>=70:
print("Your grade is C")
elif score>=60:
print("Your grade is D")
else:
print("Your grade is F")
# Question 4 — Login System
username=input("Username ")
password=input("Password ")
if username == "admin":
if password == "python123":
print("Welcome back admin!")
else:
print("Wrong password!")
else:
print("Username not found!")
# Question 5 — Shopping Discount
totalprice=int(input("Enter total price: "))
if totalprice>= 50000:
discount= 0.2*totalprice
elif totalprice>= 30000:
discount= 0.1*totalprice
elif totalprice>= 10000:
discount= 0.05*totalprice
else:
discount= 0
print(f"Original price: ₦{totalprice}")
print(f"Discount: ₦{discount}")
print(f"Final price: ₦{totalprice-discount}")
# Question 6 — BMI Calculator with Category
name=input("Enter your name: ")
weight=float(input("Enter weight in kg: "))
height=float(input("Enter height in m: "))
bmi=weight/(height**2)
if bmi<=18.5:
category= "Underweight"
elif bmi<=24.9:
category= "Normal weight"
elif bmi<=29.9:
category= "Overweight"
else:
category= "Obese"
print(f"{name} your BMI is {round(bmi,2)} and you are {category}.")