0% found this document useful (0 votes)
2 views4 pages

Nested-If Else Task

The document contains a Python script with multiple tasks that involve conditional statements. It includes programs for checking free delivery based on purchase amount, traffic signal responses, login access validation, electricity bill calculation, age-based pricing for tickets, movie ticket booking, and employee bonus calculation. Each task is structured with user input and conditional logic to determine the appropriate output.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Nested-If Else Task

The document contains a Python script with multiple tasks that involve conditional statements. It includes programs for checking free delivery based on purchase amount, traffic signal responses, login access validation, electricity bill calculation, age-based pricing for tickets, movie ticket booking, and employee bonus calculation. Each task is structured with user input and conditional logic to determine the appropriate output.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

5/21/26, 3:08 PM if_else_task.

py

daily_task\if_else_task.py

1 # 1. Write a Python program to check whether a customer gets free delivery.


2 # If the purchase amount is greater than 1000, print "Free Delivery"
3 # Otherwise print "Delivery Charges Apply"
4
5 amount = int(input("enter the purchase amount : "))
6
7 if amount > 1000 :
8 print("Free Delivery")
9
10 else:
11 print("Delivery Charges Apply")
12
13
14
15
16 # 2. Write a Python program to check whether a traffic signal is "Red", "Yellow", or
"Green".
17 # Red → "Stop"
18 # Yellow → "Ready"
19 # Green → "Go"
20
21 signal = input("enter the color (r/y/g) : ").lower()
22
23 if (signal == "r" ):
24 print("Stop")
25
26 elif(signal == "y"):
27 print("Ready")
28
29 else:
30 print("Go")
31
32
33
34 # 3. Write a Python program to check login access.
35 # If username is "admin" and password is "1234", print "Login Successful"
36 # Otherwise print "Invalid Login"
37
38 username = input("enter the username : ").lower()
39 password = int(input("enter the password : "))
40
41 if (username == "admin" and password == 1234):
42 print("Login Successful")
43
44 else:
45 print("Invalid Login")
46
47
48
49
50 # 4. Write a python program to calculate the final bill amount for a user
51
localhost:64579/21aefb47-301f-46cd-9739-ca07a545a18a/ 1/4
5/21/26, 3:08 PM if_else_task.py

52 # An electricity company charges users based on their monthly electricity consumption


53
54 # First 100 units:Rs-3 per unit
55 # Next 200 units (101-300 units):Rs-5 per unit
56 # Above 300 units: Rs-8 per unit
57
58 # Additional charger:
59 # If the bill amount exceeds Rs-1000 a 5% surcharge is added.
60 # Senior citizens(above 60 years) get a 10% discount on the total before surcharge.
61
62 unit = int(input("enter your units : "))
63 age = int(input("enter your age : "))
64
65 if unit <= 100:
66 bill = unit * 3
67
68
69 elif (unit > 100) and (unit <= 300):
70 bill = (100 * 3) + (unit - 100) * 5
71
72
73 elif (unit >= 300):
74 bill = (100 * 3) + (200 * 5) + (unit - 300) * 8
75
76 # Senior citizens(above 60 years) get a 10% discount on the total before surcharge.
77 if(age >= 60):
78 bill = bill - (10 / 100) * bill
79
80
81 # If the bill amount exceeds Rs-1000 a 5% surcharge is added.
82 if (bill > 1000):
83 bill = bill + (5/100) * bill
84
85 print(bill)
86
87
88 # 5. Age based pricing:
89 # children under 5 years-free enter
90 # children between 5 and 12 years-50% discount on the base price.
91 # senior citizens above 60 years-25% didcount on the base price.
92 # everyone else pay the full price.
93
94 # Time of the day discount:
95 # if the visit is before 11:00 AM ,there an additional 20% discount on the ticket(after
the age based discount applicable).
96
97 # VIP membership:
98 # if the visitor is a VIP membership, they get an extra 10% discount(after applying the
previous discounts)
99
100 ticket = 1000
101 age = int(input("enter your age : "))
102 time = float(input("enter your time : "))
103 vip_membership = input("enter your membership (yes / no) : ").lower()

localhost:64579/21aefb47-301f-46cd-9739-ca07a545a18a/ 2/4
5/21/26, 3:08 PM if_else_task.py

104
105 # children under 5 years-free enter
106 if(age < 5):
107 ticket = 0
108 print("your bill is free")
109
110 # children between 5 and 12 years-50% discount on the base price.
111 elif((age >= 5) and (age <= 12)):
112 ticket = ticket - (50 / 100) * ticket
113
114 # the visit is before 11:00 AM ,there an additional 20% discount
115 if (time < 11):
116 ticket = ticket - (20 / 100) * ticket
117
118 # the visitor is a VIP membership, they get an extra 10% discount
119 if (vip_membership == "yes"):
120 ticket = ticket - (10 / 100) * ticket
121
122
123 # senior citizens above 60 years-25% didcount on the base price.
124 elif(age >= 60):
125 ticket = ticket - (25 / 100) * ticket
126
127 # the visit is before 11:00 AM ,there an additional 20% discount
128 if (time < 11):
129 ticket = ticket - (20 / 100) * ticket
130
131 # the visitor is a VIP membership, they get an extra 10% discount
132 if (vip_membership == "yes"):
133 ticket = ticket - (10 / 100) * ticket
134
135
136 else:
137 if (time < 11):
138 ticket = ticket - (20 / 100) * ticket
139
140 if (vip_membership == "yes"):
141 ticket = ticket - (10 / 100) * ticket
142
143
144 print("your bill is : ",ticket)
145
146
147
148
149 # 6. Write a Python program for movie ticket booking.
150 # If seats are available, then check age category.
151 # If age is below 12 print "Child Ticket"
152 # If age is above 60 print "Senior Citizen Ticket"
153 # Otherwise print "Regular Ticket"
154
155 age = int(input("enter your age : "))
156
157 if(age < 12):
localhost:64579/21aefb47-301f-46cd-9739-ca07a545a18a/ 3/4
5/21/26, 3:08 PM if_else_task.py

158 print("Child Ticket")


159
160 elif(age > 60):
161 print("Senior Citizen Ticket")
162
163 else:
164 print("Regular Ticket")
165
166
167
168 # 7. Write a Python program for employee bonus calculation.
169 # If employee experience is above 3 years, then check performance rating.
170 # If rating is "Excellent" print "High Bonus"
171 # Otherwise print "Normal Bonus"
172 # If experience is below 3 years print "Not Eligible for Bonus"
173
174 employee_experience = float(input("enter your experience : "))
175 rating = input("enter your rating (excellent / normal) : ")
176
177 if (employee_experience >= 3):
178 if (rating == "excellent"):
179 print( "high bonus")
180
181 elif(rating == "normal"):
182 print("normal bonus")
183 else:
184 print("Not Eligible for Bonus")
185
186 else:
187 print("Not Eligible for Bonus")
188
189

localhost:64579/21aefb47-301f-46cd-9739-ca07a545a18a/ 4/4

You might also like