1) Chocolate Wrapper Problem
You have Rs. 100 /- One chocolate costs Rs. 5. Every time you buy a chocolate, you get one wrapper. You can exchange 3 wrappers for 1 additional chocolate. What is the maximum number of chocolates you can have with Rs. 100?
ANS:
rs=100
chocolate=rs//5
wraper=3
subwrap=chocolate
while subwrap>=wraper:
newchoco=subwrap//wraper
chocolate+=newchoco
subwrap=newchoco+(subwrap%wraper)
print(chocolate)
Explanation :
Line 1 : You have a total rs of 100
Line 2 : Per chocolate cost rs=5 show that you can buy 20 chocolate by dividing 100 by 5 and uses // to get a whole number without a decimal value.
Line 3 : For 3 Wrapper you can exchange a chocolate
Line 4 : so we buy some amount like 20 chocolate we assign that to subwrap variable to further processing
Line 5: while subwrap>=wraper: starts a loop that keeps running as long as you have at least 3 wrappers available to exchange.
Line 6: newchoco=subwrap//wraper calculates how many new whole chocolates you can get by dividing your current wrappers by 3.
Line 7: chocolate+=newchoco adds those newly earned chocolates to your total chocolate count.
Line 8: subwrap=newchoco+(subwrap%wraper) updates your wrapper count by adding the new wrappers from the fresh chocolates to any leftover wrappers that could not be traded.
Line 9: print(chocolate) displays the final maximum number of chocolates you collected once you have fewer than 3 wrappers left.



