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

Python If-Else Practice Questions

The document contains a series of Python practice questions focused on conditional statements, covering various scenarios in discounts, tax calculations, shopping, travel, and academic performance. Each section includes specific tasks such as checking discount eligibility, calculating taxes, and determining student grades based on given criteria. The exercises are designed to enhance programming skills by applying if-else logic in practical situations.

Uploaded by

hammad0007000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Python If-Else Practice Questions

The document contains a series of Python practice questions focused on conditional statements, covering various scenarios in discounts, tax calculations, shopping, travel, and academic performance. Each section includes specific tasks such as checking discount eligibility, calculating taxes, and determining student grades based on given criteria. The exercises are designed to enhance programming skills by applying if-else logic in practical situations.

Uploaded by

hammad0007000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python If Else Practice Questions

A- Discounts and Pricing

1. Check Discount Eligibility


Write a program to check if a customer is eligible for a discount. If the total purchase is
more than $100, apply a 10% discount and display the final price. Otherwise, display the
total price as it is.

2. Calculate Bulk Discount


If a customer buys more than 5 items, apply a 15% discount on the total price. Otherwise,
no discount is applied. Display the total price.

3. Membership Discount
Check if the customer is a member (is_member = True). Members get a 20% discount;
non-members get a 5% discount. Calculate and print the discounted price.

4. Seasonal Sale
If today is a holiday (is_holiday = True), apply a 25% discount; otherwise, apply a 10%
discount. Calculate the price after discount.

5. Buy-One-Get-One-Free
If a customer buys an even number of items, they get half of them for free. Otherwise,
they pay for all. Calculate the number of items the customer has to pay for.

B- Tax Calculations

6. Sales Tax
If the price of an item is greater than $500, apply a luxury tax of 15%. Otherwise, apply a
standard tax of 8%. Display the total price after tax.

7. Income Tax
If a person's annual income is above $50,000, they pay 20% tax. Otherwise, they pay
10%. Calculate and display the tax amount.

8. Tax Bracket
Write a program to categorize a person into tax brackets:
 Income < $30,000: "Low Tax"
 $30,000 ≤ Income < $100,000: "Medium Tax"
 Income ≥ $100,000: "High Tax"

9. VAT Calculation
If the item is marked as essential (is_essential = True), apply a VAT of 5%. Otherwise,
apply a VAT of 12%. Display the final price.

10. Tax-Free Day


If today is a tax-free day (tax_free = True), display the original price. Otherwise, add a
7% tax.
C- Shopping and Billing
11. Free Shipping
If the total purchase amount is more than $50, offer free shipping; otherwise, charge $5
for shipping. Display the total amount including shipping.

12. Discount Code


If a customer enters the correct discount code (DISCOUNT10), apply a 10% discount.
Otherwise, charge the full amount.

13. Tiered Discounts


Apply discounts based on the total price:
 $0–$50: No discount.
 $50–$100: 10% discount.
 Over $100: 20% discount.

14. Minimum Purchase Requirement


If the total amount is less than $20, display a message: "Minimum purchase of $20 is
required." Otherwise, display the total amount.

15. Loyalty Points


If a customer is a loyal member (is_loyal = True), they earn double loyalty points for
their purchase. Otherwise, they earn standard points.

D- Travel and Tickets

16. Travel Discount


If a person is traveling more than 500 miles, offer a 20% discount on ticket price.
Otherwise, charge the full amount.

17. Child or Senior Discount


If a passenger is under 12 or over 60 years old, apply a 15% discount on the ticket price.
Otherwise, charge the full price.

18. Ticket Type Pricing


If the ticket is for a weekend (is_weekend = True), add a 10% surcharge. Otherwise,
charge the standard price.

19. Baggage Fee


If the total baggage weight is over 20kg, charge $10 per extra kilogram. Otherwise, no
extra fee.

20. Early Bird Discount


If a ticket is booked more than 30 days in advance, apply a 10% discount. Otherwise,
charge the full price.
E- Grades and Performance

21. Pass or Fail


If a student scores 40 or more, print "Pass". Otherwise, print "Fail".

22. Grade Assignment


Based on a student's score, assign grades:
 90 and above: "A"
 75–89: "B"
 50–74: "C"
 Below 50: "F"

23. Bonus Marks


If a student completes all assignments, add 5 bonus marks to their score. Otherwise, no
bonus marks.

24. Attendance Eligibility


If a student's attendance is 75% or more, they are eligible to take the exam. Otherwise,
they are not.

25. Scholarship Eligibility


If a student's grade is "A" and their annual family income is below $30,000, they are
eligible for a scholarship. Otherwise, they are not.

Common questions

Powered by AI

A progressive tax system, as described in Source 1, taxes higher incomes at higher rates, like the 'Low,' 'Medium,' and 'High Tax' brackets. This approach can redistribute wealth more equitably and reduce income inequality, positively affecting socio-economic mobility by funding public services. In contrast, a flat tax system taxes all income levels at the same percentage, simplifying compliance but potentially widening income inequality due to less redistributive effect, as lower-income individuals pay the same proportion of tax as high-income earners .

A tiered discount structure creates nuanced pricing models that compel customers to consider their purchases more strategically, potentially moving towards higher expenditure brackets to achieve greater savings. From a strategic standpoint, it allows businesses to differentiate price points and maximize revenue from different customer segments, effectively appealing to both budget-conscious and high-spending consumers by incentivizing increased spending for greater discounts .

To calculate the final price when both a membership and a seasonal sale are active, we could apply the discounts sequentially. First, apply the membership discount: if the customer is a member, reduce the price by 20%; if not, reduce it by 5%. Then, apply the seasonal sale discount: if today is a holiday, reduce the remaining amount by 25%; otherwise, reduce it by 10%. These calculations are crucial for determining the cumulative discount provided to the customer, especially since percentages compound as opposed to simply adding up .

An early bird discount policy incentivizes customers to book tickets well in advance, allowing the travel company to secure early revenue and improve cash flow while reducing uncertainty in demand forecasting. Though it temporarily reduces the ticket price (by 10%), greater demand stability may lead to improved financial planning and potentially decreased marketing costs. Ultimately, the policy promotes higher occupancy rates, thus optimizing overall resource utilization .

The rationale for differing VAT rates is to lessen the financial burden on essential items—goods and services deemed necessary for basic living. A lower VAT of 5% for essentials means consumers are less deterred from purchasing important items, whereas non-essential items carry a higher VAT of 12% to dissuade excessive consumption. This generally encourages spending on necessary goods and limits expenditure on luxury items, reflecting a progressive tax approach aimed at supporting lower-income individuals .

Enforcing a minimum purchase requirement ensures efficient logistics and profitability, as processing small transactions can be less cost-efficient relative to the revenue generated. However, the downside could be consumer dissatisfaction and loss of sales if customers feel restricted or coerced into spending more than intended, potentially driving them to competitors without such limits. Balancing customer experience with business needs is critical to successfully implementing such policies .

If a customer buys a prime number of items, they don't benefit fully from a Buy-One-Get-One-Free promotion, which works optimally when the number of items is even. For example, if they buy 5 items (a prime number), only 2 items can be free, meaning they would still need to pay for 3 items because the promotion applies only to pairs of items .

Offering free shipping for purchases over $50 can encourage consumers to spend more to meet the threshold, thus increasing the average order value. Customers often perceive shipping fees as an unnecessary additional cost; by setting a minimum purchase requirement to waive it, retailers provide a psychological incentive to buy more, enhancing sales and potentially improving customer satisfaction and loyalty .

Sales taxes, luxury taxes, and VATs collectively shape consumer behavior by altering the perceived cost-effectiveness of purchases. High taxes on luxury goods deter excessive non-essential consumption, aligning with socio-economic strategies to promote fiscal responsibility and equity through differential impacts on spending power. The economic behavior is thus influenced by strategic resource allocation, as consumers navigate the trade-offs between luxury spending and savings .

Granting double loyalty points to loyal members can significantly improve customer retention by providing extra value for continuous patronage. Over time, as customers accumulate more points, they may perceive increased brand value and exclusivity, discouraging them from shifting to competitors. However, while enhancing retention, this strategy must be balanced with profitability considerations to ensure that the cost of extra loyalty points does not outweigh the benefits of increased sales and customer loyalty .

You might also like