Python practice: The Python Standard Library & Projects

Chapter 16 · 8 questions · included in full access

  1. Question 1 · easy

    Math square root and ceiling

    Import math. Calculate math.isqrt(144) on line 1 and math.ceil(4.2) on line 2, and print both:

    Solve it in your browser
  2. Question 2 · easy

    Compute median with statistics module

    Import statistics. Given sales = [1200, 3400, 850, 4100, 2900], print statistics.median(sales):

    Solve it in your browser
  3. Question 3 · easy

    Calculate invoice Net 30 due date

    From datetime import date, timedelta. Given inv = date(2026, 4, 15), compute due = inv + timedelta(days=30) and print due:

    Solve it in your browser
  4. Question 4 · easy

    Days between two dates

    From datetime import date. Compute the days between start = date(2026, 4, 1) and end = date(2026, 4, 25) using (end - start).days. Print the days:

    Solve it in your browser
  5. Question 5 · easy

    Tally rep orders with Counter

    From collections import Counter. Given reps = ["Asha", "Ravi", "Asha", "Priya", "Asha"], count with counts = Counter(reps). Print counts["Asha"]:

    Solve it in your browser
  6. Question 6 · easy

    Find most common item with Counter

    From collections import Counter. Given cats = ["Desk", "Chair", "Desk", "Desk", "Lamp"], print Counter(cats).most_common(1)[0][0]:

    Solve it in your browser
  7. Question 7 · medium

    Parse CSV data with csv.DictReader

    Import csv, io. Given csv_text = "Rep,Sales\nAsha,1400\nRavi,2200\n", parse with csv.DictReader(io.StringIO(csv_text)) and print the total sales sum 3600:

    Solve it in your browser
  8. Question 8 · medium

    Write structured CSV rows

    Import csv, io. Create out = io.StringIO(), create writer = csv.writer(out), write row ["Rep", "Rev"] and row ["Asha", "1200"]. Print out.getvalue().strip():

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing