-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path05_Practice.py
More file actions
115 lines (93 loc) · 2.88 KB
/
05_Practice.py
File metadata and controls
115 lines (93 loc) · 2.88 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Check if a number is positive
num = int(input("Enter a number:"))
res = "Positive" if num > 0 else "Negative"
print(res)
# Check if a student is pass/fail in exam
marks = int(input("Enter student marks: "))
result = "Pass" if marks >= 40 else "Fail"
print(result)
# Check if a user has balance to buy an item
balance = float(input("Enter your balance: "))
price = float(input("Enter the item price: "))
remark = "You can Purchase" if balance >= price else "You can't afford"
print(remark)
# Suggest a mode of transport based on distance
distance = float(input("Enter distance you want to travel: "))
if distance <= 2:
print("You can go by walk")
elif distance <= 10:
print("You can travel by bicycle or scooter")
elif distance <= 50:
print("You can go with any pubic transport")
else:
print("Consider a train or flight")
# Battery status
battery = int(input("Enter battery percentage: "))
if battery > 80:
print("Battery Full")
elif battery > 40:
print("Battery Half")
else:
print("Battery Low")
# Nested if-else Statement
# Login with username and password
username = input("Enter your username: ")
password = input("Enter your password: ")
if username == "Admin":
if password == "123":
print("Access Granted")
else:
print("Incorrect Password")
else:
print("Enter correct Username")
# Check exam pass and scholarship eligibility
marks1 = int(input("Enter your Marks: "))
if marks1 >= 50:
if marks1 >= 85 and marks1 <=100:
print("Eligible for Scholarship")
else:
print("Not Eligible for Scholarship")
else:
print("Failed")
# Ternary Statement
n = int(input("Enter a number: "))
print("even" if n%2==0 else "odd")
temp = int(input("Enter the temperature: "))
print("Hot" if temp > 25 else "Cool")
# Assign grade
Grade = input("Enter your Grade (S/A/B/C): ").upper()
match Grade:
case "S":
print("Super")
case "A":
print("Excellent")
case "B":
print("Good")
case "C":
print("Average")
case _:
print("Fail")
# Activity Suggestion based on weather condition
weather = input("Enter the weather (sunny/rainy/cloudy/snowy): ").lower()
match weather:
case "sunny":
print("Great day for an picnic!")
case "rainy":
print("Stay indoors and read a book.")
case "cloudy":
print("Build a snowman or go skiing.")
case _:
print("Unknown weather condition.")
# Mobile notification settings based on user profile mode
mode = input("Enter phone mode (silent/vibrate/loud/do not disturb): ").lower()
match mode:
case "silent":
print("Notifications are muted.")
case "vibrate":
print("Phone will vibrate for notifications.")
case "loud":
print("All notifications will play sound.")
case "do not disturb":
print("No calls or notifications will come through.")
case _:
print("Invalid mode selected.")