Python practice: The Python Standard Library & Projects
Chapter 16 · 8 questions · included in full access
Question 1 · easy
Math square root and ceiling
Solve it in your browserImport
math. Calculatemath.isqrt(144)on line 1 andmath.ceil(4.2)on line 2, and print both:Question 2 · easy
Compute median with statistics module
Solve it in your browserImport
statistics. Givensales = [1200, 3400, 850, 4100, 2900], printstatistics.median(sales):Question 3 · easy
Calculate invoice Net 30 due date
Solve it in your browserFrom
datetimeimportdate, timedelta. Giveninv = date(2026, 4, 15), computedue = inv + timedelta(days=30)and printdue:Question 4 · easy
Days between two dates
Solve it in your browserFrom
datetimeimportdate. Compute the days betweenstart = date(2026, 4, 1)andend = date(2026, 4, 25)using(end - start).days. Print the days:Question 5 · easy
Tally rep orders with Counter
Solve it in your browserFrom
collectionsimportCounter. Givenreps = ["Asha", "Ravi", "Asha", "Priya", "Asha"], count withcounts = Counter(reps). Printcounts["Asha"]:Question 6 · easy
Find most common item with Counter
Solve it in your browserFrom
collectionsimportCounter. Givencats = ["Desk", "Chair", "Desk", "Desk", "Lamp"], printCounter(cats).most_common(1)[0][0]:Question 7 · medium
Parse CSV data with csv.DictReader
Solve it in your browserImport
csv, io. Givencsv_text = "Rep,Sales\nAsha,1400\nRavi,2200\n", parse withcsv.DictReader(io.StringIO(csv_text))and print the total sales sum3600:Question 8 · medium
Write structured CSV rows
Solve it in your browserImport
csv, io. Createout = io.StringIO(), createwriter = csv.writer(out), write row["Rep", "Rev"]and row["Asha", "1200"]. Printout.getvalue().strip():
These questions are part of full access.
The first chapters of every track are free. Full access is a one-time payment.
See pricing