0% found this document useful (0 votes)
25 views3 pages

Python Conditional Statements Worksheet

The document contains a worksheet for class 7 students focusing on Python conditional statements through various case studies. Each case study presents a coding scenario involving conditions and asks questions related to outputs and modifications of variables. The document emphasizes understanding of conditional logic and the use of keywords for multiple conditions.

Uploaded by

swan07053
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)
25 views3 pages

Python Conditional Statements Worksheet

The document contains a worksheet for class 7 students focusing on Python conditional statements through various case studies. Each case study presents a coding scenario involving conditions and asks questions related to outputs and modifications of variables. The document emphasizes understanding of conditional logic and the use of keywords for multiple conditions.

Uploaded by

swan07053
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

Worksheet -2 class 7

Python Conditional Statements Worksheet

Case Study 1 – Weather Advisory Program


Code:
name = "Riya"
temperature = 28
extra = 2
current_temp = temperature + extra

if current_temp >= 35:


advice = "Carry water bottle"
elif current_temp >= 25:
advice = "Wear sunglasses"
elif current_temp >= 15:
advice = "Carry a light jacket"
else:
advice = "Stay warm with woolens"

print(name + " should follow advice:", advice)

Questions: a) What will be the output?


b) If temperature = 20 and extra = 5, what advice?
c) If temperature = 10 and extra = 3, what advice?
d) What happens if extra = -10?
e) Which keyword is used for multiple conditions?

Case Study 2 – Shopping Discount Program


Code:
name = "Rahul"
purchase = 450
discount = 50
total_amount = purchase - discount

if total_amount >= 500:


offer = "10% off on next purchase"
elif total_amount >= 300:
offer = "Free delivery"
else:
offer = "No offer"

print(name + " gets:", offer)

Questions: a) Output? What will be the output?


b) If purchase = 600 and discount = 100?
c) If purchase = 250 and discount = 30?
d) What if discount = -50?
e) Which Keyword is used for multiple conditions?

Case Study 3 – Exam Pass/Fail Checker


Code:
name = "Sneha"
marks = 45
extra = 10
total = marks + extra

if total >= 80:


result = "Distinction"
elif total >= 50:
result = "Pass"
else:
result = "Fail"

print(name + " result:", result)

Questions: a) What will be the output?


b) marks = 40, extra = 15?
c) marks = 70, extra = 5?
d) extra = -20?
e) Keyword for multiple conditions?

Case Study 4 – Movie Ticket Pricing


Code:
name = "Amit"
age = 14
extra = 2
final_age = age + extra

if final_age >= 60:


ticket_price = 100
elif final_age >= 18:
ticket_price = 200
else:
ticket_price = 50

print(name + " ticket price is:", ticket_price)

Questions: a) What will be the output?


b) age = 17, extra = 3?
c) age = 61, extra = 0?
d) extra = -5? e)
Keyword for multiple conditions?
Case Study 5 – Speed Limit Warning
Code:
driver = "Neha"
speed = 75
adjust = -5
final_speed = speed + adjust

if final_speed > 100:


warning = "High Speed! Slow down"
elif final_speed > 60:
warning = "Moderate speed"
else:
warning = "Safe speed"

print(driver + " driving status:", warning)

Questions: a) What will be the output?


b) speed = 55, adjust = 10?
c) speed = 110, adjust = -15?
d) adjust = -70?
e) Keyword for multiple conditions?

Case Study 6 – Bank Interest Rate


Code:
name = "Karan"
balance = 12000
bonus = 3000
total_balance = balance + bonus

if total_balance >= 20000:


interest = "5%"
elif total_balance >= 10000:
interest = "3%"
else:
interest = "1%"

print(name + " will get interest rate:", interest)

Questions: a) What will be the output?


b) balance = 8000, bonus = 3000?
c) balance = 25000, bonus = 0?
d) bonus = -5000?
e) Keyword for multiple conditions?

Common questions

Powered by AI

A balance of 25,000 with no bonus results in a total_balance of 25,000, which qualifies for the highest interest rate of 5% if conditions follow the provided logic .

With a purchase of 600 and a discount of 100, the total amount is 500. The condition total_amount >= 500 activates the offer '10% off on next purchase' because the total amount meets this criterion .

An adjust of -70 results in a final speed reduction below safe thresholds defined, thus outputting 'Safe speed' for drastic slowdowns in speed assessments to even within broad safety margins, highlighting system flexibility in managing excessive adjustments .

The keyword 'elif' is used to manage multiple conditions sequentially by checking various branches after an 'if' statement .

The advice will be 'Stay warm with woolens' as the current_temp is 13, which is less than 15, activating the condition to stay warm .

The output is 'Sneha result: Pass'. The total is 55, meeting the condition for passing (total >= 50).

The advice will be 'Wear sunglasses' as the current temperature would be 25. The condition current_temp >= 25 triggers the 'Wear sunglasses' advice .

A 'Free delivery' offer is given when total_amount is 300 or more but less than 500. This is the outcome of the condition elif total_amount >= 300 .

Using extra = -10, the current_temp decreases by 10, potentially changing advice unexpectedly when negative adjustments are not anticipated. The remaining logic still technically holds, as conditions adapt to any number, maintaining function but possibly misaligned user expectation .

With an age of 61 and extra 0, final_age is 61, meeting the criterion for 100 ticket price, marking amended pricing logic for senior tickets as per defined age thresholds .

You might also like