Skills101
← Python — Intermediate

Python Intermediate — Test 1

15 questions19 minPass: 60%+30 XP on first passFree sample test

15 questions · 19 minutes · intermediate level, with an explanation for every answer.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What is the output?

    def add(item, box=[]):
        box.append(item)
        return box
    
    add(1)
    print(add(2))
    
  2. Question 2

    What is the output?

    s = {3, 1, 3, 2, 1}
    t = {2, 3, 4}
    print(len(s), sorted(s & t), sorted(s - t))
    
  3. Question 3

    What is the output?

    a = [1, 2, 3]
    b = a
    b.append(4)
    c = a[:]
    c.append(5)
    print(len(a), len(b), len(c))
    
  4. Question 4

    What is the output?

    f = lambda x, y=2: x ** y
    print(f(3), f(2, 5), list(map(f, [1, 4])))
    
  5. Question 5

    What is the output?

    print([x * x for x in range(6) if x % 2])
    
  6. Question 6

    What is the time complexity of checking x in my_set for a Python set (average case)?

  7. Question 7

    What is the output?

    text = "the cat and the hat"
    freq = {}
    for w in text.split():
        freq[w] = freq.get(w, 0) + 1
    print(max(freq, key=freq.get), freq["the"])
    
  8. Question 8

    What is the output?

    d = {"a": 1, "b": 2}
    d["c"] = d.get("a", 0) + d.get("z", 10)
    print(d["c"], len(d))
    
  9. Question 9

    Which statement about is and == is correct?

  10. Question 10

    What is the output?

    def f(*args, **kwargs):
        return len(args), sorted(kwargs)
    
    print(f(1, 2, 3, x=4, y=5))
    
  11. Question 11

    What does with open("a.txt") as f: guarantee?

  12. Question 12

    What is the output?

    words = ["kiwi", "fig", "banana", "apple"]
    print(sorted(words, key=len)[:2])
    
  13. Question 13

    A function has no return statement. What does calling it give back?

  14. Question 14

    What is the output?

    nums = [5, 3, 8, 1]
    nums.sort(reverse=True)
    print(nums.index(3), nums.pop(), nums)
    
  15. Question 15

    What is the output?

    try:
        print(int("12a"))
    except ValueError:
        print("bad")
    else:
        print("ok")
    finally:
        print("done")
    
🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →