Python Standard Library MCQ Test: 200 Interview Questions With Answers

← All Python MCQ topics and your readiness dashboard

Test your Standard Library: datetime, re, os, collections knowledge with a timed Python MCQ mock test for interviews. Each attempt gives you 20 random questions in 20 minutes from a 200-question bank covering date, datetime and timedelta, strftime and strptime, time zones and naive versus aware datetimes, regular expressions with search, match, fullmatch, groups and flags, os and os.path, environment variables, shutil, Counter, defaultdict, deque, namedtuple and ChainMap, plus decimal, statistics, hashlib, base64, urllib.parse and bisect, with QA uses such as boundary dates, OTP extraction, log masking and percentiles. 44 questions are written from a QA and test-automation angle and the rest from a developer angle; your result shows both scores.

What this Python MCQ test covers

Revise these lessons from the free Python tutorial before or after your test:

Sample Python Standard Library questions with answers

  • Q. Checking that dates in a UI table are sorted newest first. What does this code print?
    from datetime import datetime
    shown = ["03 Nov 2026", "28 Oct 2026", "01 Nov 2026"]
    parsed = [datetime.strptime(s, "%d %b %Y") for s in shown]
    print(parsed == sorted(parsed, reverse=True))

    Answer: False
    Parse the displayed text into datetimes before checking the order; here 01 Nov is out of place.
  • Q. Validating an order id format from an API. What does this code print?
    import re
    ids = ["ORD-2026-000123", "ORD-26-123", "ord-2026-000124"]
    print([i for i in ids if not re.fullmatch(r"ORD-\d{4}-\d{6}", i)])

    Answer: ['ORD-26-123', 'ord-2026-000124']
    fullmatch rejects both the short year and the lower-case prefix.
  • Q. Extracting a confirmation code from an email body. What does this code print?
    import re
    body = "Hi Asha, your code is 482913. It expires in 10 minutes."
    m = re.search(r"\b(\d{6})\b", body)
    print(m.group(1) if m else "no code")

    Answer: 482913
    A word-bounded six-digit pattern finds OTP codes in test emails.
  • Q. What does this code print?
    from datetime import date
    d = date(2026, 11, 3)
    print(d.year, d.month, d.day, d.isoformat())

    Answer: 2026 11 3 2026-11-03
    A date has year, month and day; isoformat gives YYYY-MM-DD.
  • Q. What does this code print?
    from datetime import date
    print(date(2026, 11, 3).weekday(), date(2026, 11, 3).isoweekday())

    Answer: 1 2
    weekday(): Monday is 0; isoweekday(): Monday is 1. 3 Nov 2026 is a Tuesday.
  • Q. What does this code print?
    from datetime import date, timedelta
    print(date(2026, 12, 30) + timedelta(days=3))

    Answer: 2027-01-02
    timedelta arithmetic rolls over months and years.

Every predict-the-output question in this bank was run on Python 3, so the answer is the real output. Go back to the Python MCQ dashboard to see your overall Python learning progress and interview readiness.

Frequently asked questions

How many questions does the Python Standard Library MCQ test have?

The bank has 200 questions. Each test picks 20 at random, favouring questions you have not seen yet, so about 10 attempts cover the whole bank.

How long is each test and what is the pass mark?

Each test has a 20-minute timer and submits itself when time runs out. You pass with 70%, which is 14 of 20 correct.

Is this test useful for QA and automation engineer interviews?

Yes. 44 of the questions use test-automation scenarios such as parsing UI text, test data and assertions, and your result shows your QA score separately.

Can I retake the test?

Yes, as often as you like. Every retake draws a fresh set of 20 questions and counts toward your 20-test readiness target.