Class12CBSEComputerScience
Application-BasedPython Functions Worksheet
Topic: Python Functions
TotalQuestions: 5 Marks:20
Instructions
WritePythonprogramsusinguser-defined functions(def).
Usepropervariablenamesand indentation.
Displaymeaningfuloutputmessages.
Eachquestioncarries4 marks.
1. ElectricityBill Calculator
WriteaPythonfunctionbil (units) tocalculatetheelectricitybillbasedonthefollowing
conditions:
-First100units→₹2perunit
-Next100units→₹3perunit
-Above200units→₹5perunit
Theprogramshould:
-Acceptthenumberofunitsconsumedfromtheuser
-Call thefunction
-Displaythetotal electricity bill
2. Student ResultAnalyzer
WriteaPythonfunctionresult(mark1, mark2, mark3, mark4,mark5)that:
-Calculatesthetotalmarks
-Calculatestheaverage
-Displays“Pass” if averageis greaterthanorequalto40
-Otherwisedisplays“Fail”
Theprogramshould acceptmarksof5 subjectsfromtheuser.
3. ATM Cash Withdrawal System
WriteaPythonfunctionwithdraw(balance, amount) that:
-Checkswhetherthewithdrawalamountis lessthanorequalto thebalance
-Deductstheamountif possible
-Displaystheremainingbalance
-Otherwisedisplays“InsufficientBalance”
Accepttheaccountbalanceand withdrawalamountfromtheuser.
4. OnlineShopping Discount Calculator
WriteaPythonfunctiondiscount(price) thatcalculatesthefinal amountafterdiscount.
DiscountConditions:
-Purchaseabove₹5000→20%discount
-Purchaseabove₹2000→10%discount
-Otherwise→Nodiscount
Theprogramshould:
-Acceptthepurchaseamount
-Displaythediscountamountandfinal bill
5. Hospital BMIChecker
WriteaPythonfunctionbmi(weight,height)tocalculateBodyMassIndex usingthe
formula:
BMI =weight/ (height*height)
Thefunctionshould display:
-“Underweight”ifBMI<18.5
-“Normal”if BMIisbetween18.5and24.9
-“Overweight”if BMI is 25orabove
Theprogramshould acceptweight(inkg)and height(inmeters)fromtheuser.
ChallengeTask
Modify any oneoftheaboveprogramsusing:
-Returnstatement
-Menu-drivenapproach
-Multiplefunctions