Skip to content

Lab · Python Programming

Lab: a clean UPI receipt

Labbeginner· about 1.5 hours· 5 steps

The brief

A payment app exported one UPI payment with messy text. Clean the UPI ID, hide most of the reference number, print a tidy receipt and work out the cashback with if, elif and else.

Why it matters

Payment apps, banks and shop billing software clean text like this all day. Users type names in any case and with stray spaces, and receipts must hide most of a reference number. Offers like cashback are simple if/elif/else rules.

Skills you practise

  • string methods
  • slicing
  • f-strings and format specs
  • if, elif and else
  • booleans with and / not

What you will have at the end

receipt.py: a program that cleans a UPI payment's text, prints a receipt line and works out the cashback.

How it is marked (rubric, 100 points)
Correct resultsAll five checks pass, including the 2,000-rupee boundary for cashback.50
Right string toolsstrip(), lower(), title(), a negative slice and an f-string format spec, each used where it fits.20
Clear decisionsif, elif and else in the right order, biggest band first, with >= for "or more".20
Readable codeComments say what each step does, and the variable names are clear.10

0/5 steps done

Step 1 of 5

Clean the UPI ID

clean_id holds the UPI ID with no spaces at either end and all in lower case ("priya.sharma@okaxis").

UPI IDs are not case-sensitive, so apps store them in lower case. strip() removes spaces at both ends and lower() makes every letter small. String methods give you a new string; they never change the original, so store the result in clean_id.

Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.