Data Structures and Algorithms (DSA27) · Week 1

Why this course · Python basics (Lecture 01, Lab 01)

These quizzes are for self-study. Your answers are saved on this device only and are not sent anywhere.

Score: 0 / 42 · Answered: 0

  1. W1-M01 Recall

    "Every general-purpose programming language is Turing-complete." What does that tell you?

  2. W1-M02 Recall

    Python's type system is best described as:

  3. W1-M03 Apply

    What does "3" + 5 do in Python?

  4. W1-M04 Recall

    How does Rust manage memory?

  5. W1-M05 Recall

    Where and why was C created?

  6. W1-M06 Recall

    An Abstract Data Type specifies:

  7. W1-M07 Apply

    Which of these is the declarative (comprehension) style from Lecture 01?

  8. W1-M08 Recall

    What does the TIOBE index actually count?

  9. W1-M09 Explain

    In the course's three levels of knowledge, which is know-why?

  10. W1-M10 Recall

    To pass this course, a student needs:

  11. W1-M11 Apply

    What is -7 // 2?

  12. W1-M12 Apply

    What is -7 % 3?

  13. W1-M13 Apply

    What is 2 ** 3 ** 2?

  14. W1-M14 Apply

    What is type(8 / 4)?

  15. W1-M15 Apply

    With word = "Python", what is word[1:4]?

  16. W1-M16 Apply

    What is "Mansoura"[::-2]?

  17. W1-M17 Apply

    After a = [1, 2, 3], b = a, b.append(4), what is a?

  18. W1-M18 Apply

    After a = [1, 2] and c = a[:], what are c is a and c == a?

  19. W1-M19 Apply

    grid = [[0] * 2] * 2, then grid[0][0] = 1. What is grid?

  20. W1-M20 Recall

    What is round(2.5) + round(3.5)?

  21. W1-M21 Explain

    Why is 0.1 + 0.2 == 0.3 False in Python?

  22. W1-M22 Apply

    What happens when you run s = "abc" then s[0] = "z"?

  23. W1-M23 Apply

    A function's body is print(width * height) and nothing else. What does x = area(3, 4) store in x?

  24. W1-M24 Apply

    What does int("4.5") do?

  25. W1-M25 Explain

    In C, reading a[10] from a 5-element array returns whatever happens to be in memory; in Python, a[10] on a 5-element list raises IndexError. Which explanation matches Lecture 01?

  26. W1-M26 Apply

    What does Python print for 2 ** 64 + 1?

  27. W1-M27 Explain

    Why do the course's exercises never call input()?

  28. W1-M28 Apply

    What is f'{7:03d}|{3.14159:.2f}'?

  29. W1-M29 Apply

    What does this print?

    a = [1, 2, 3]
    b = a
    a = a + [4]
    b.append(5)
    print(a, b)
  30. W1-M30 Explain

    xs = [42, "hello", 3.14] holds an int, a str and a float in one list. Why is that possible?

  31. W1-M31 Recall

    Lecture 01 lists three properties we care about in an algorithm. In the lecture's order, they are:

  32. W1-M32 Explain

    You time linear and binary search on a sorted list of 20 items, and linear search is faster. Does this contradict "binary search is O(log n), linear search is O(n)"?

  33. W1-M33 Apply

    An O(n2) program takes 2 seconds on today's data. The data grows ten times larger. About how long will it take now?

  34. W1-M34 Explain

    TIOBE ranked Visual Basic above Rust in September 2026. What does Lecture 01 conclude from rankings like this?

  35. W1-M35 Recall

    What is 'a,b,,c'.split(',')?

  36. W1-M36 Explain

    A shop stores prices in pounds as float values and adds them up. Why does Lab 01 say not to, and what should it do instead?

  37. W1-M37 Recall

    What do 'banana'.find('z') and 'banana'.index('z') do?

  38. W1-M38 Explain

    Lecture 01 calls Python's built-in list, dict, sorted and heapq "the honest case against Python — for us". Why are they a problem in this course?

  39. W1-M39 Recall

    Which pairing of designer, language and decision is correct?

  40. W1-M40 Explain

    Lecture 01 says you cannot write badly-indented Python. Why?

  41. W1-M41 Apply

    What does this print?

    def min_max(a, b):
        if a < b:
            return a, b
        return b, a
    
    result = min_max(9, 2)
    print(type(result).__name__, result[0])
  42. W1-M42 Apply

    What does this print?

    grid = [[0, 0], [0, 0]]
    copy = grid[:]
    copy[0][0] = 9
    copy[1] = [7, 7]
    print(grid)

36 marks

Written questions

10 written questions (36 marks). Write your answer first, then open the model answer and its marking points, and mark yourself honestly: each point is worth about one mark.

Written total: 0 / 36

  1. W1-E1 Explain 4 marks

    "All programming languages are the same; only the syntax differs." Explain what is true in this statement and what is wrong with it. Give one concrete example of a design decision that makes two languages genuinely different.

  2. W1-E2 Explain 4 marks

    Explain the two independent axes of type systems. Place Python and JavaScript on both axes, and show with one expression how their behaviour differs.

  3. W1-E3 Recall 3 marks

    Describe the three approaches to memory management from Lecture 01, naming one language that uses each. Which one does Python use, and why does that make data structures harder to see in Python?

  4. W1-E4 Explain 4 marks

    Distinguish an Abstract Data Type from a data structure. Illustrate with the Stack ADT and two different structures that implement it.

  5. W1-E5 Explain 3 marks

    Give two reasons the course uses Python, and the honest drawback of Python for this course. How does the course deal with that drawback?

  6. W1-E6 Explain 3 marks

    "In Python a variable is not a box holding a value; it is a name bound to an object." Explain this with a short code example and a diagram, and state one consequence for lists.

  7. W1-E7 Explain 4 marks

    "Measure, do not assert." Explain why the course asks you to measure an algorithm's cost, what a measurement shows that a Big-O table does not, and one way a measurement can mislead you, with how to avoid it.

  8. W1-E8 Explain 3 marks

    "print is not return." Explain the difference with a two-line function, say what a test sees in each case, and explain why the exercises use parameters and return rather than input() and print().

  9. W1-E9 Explain 4 marks

    "Which language is best?" is not a question. Rewrite it as the real questions it hides, and explain why the ecosystem of a language matters more than its syntax, naming at least three parts of an ecosystem.

  10. W1-E10 Apply 4 marks

    Compare Python's int and float with C's int: what happens when a value gets very large, what that costs, and why 0.1 + 0.2 == 0.3 is False. State the two rules Lab 01 gives for working with floats.