📋 Lists & Tuples

Lists & Tuples: A list is like a numbered shopping list — each item sits in order, and you can call any item by its number (index).

A list is like a numbered shopping list — each item sits in order, and you can call any item by its number (index). In Java, ArrayList does this job — but you need to write a generic type, import it, and think about capacity upfront. In Python, [1, 2, 3] is enough. Where does that simplicity come from? A Python list can hold mixed TYPES at once ([1, "two", True] is valid!) — it trades away Java's type-safety in exchange for speed and flexibility. So what's the cost in QA? If a function expects a "list of test IDs" but someone accidentally slips in a number where a string belonged, Python won't notice until it actually runs — Java's compiler would have stopped you instantly.

Python list is Java's ArrayList. No import needed, no generic types. [1, 2, 3] is all you need. Lists can hold mixed types.

Micro Lab: Python coding practice

Replace the TODO line with the critical line from the expected solution. This is not a real runtime; the goal is to reinforce writing the correct structure in a controlled way.

Step by Step: Python coding practice

Read inputs and data types

Complete the critical line with the smallest change

Run the code and compare expected output

If it fails, read traceback or assertion message

Make the result reusable for a test report

What is the safe order for running Python QA code?

Java vs Python — Lists

If tests = ["a","b","c"], what does tests[-1] return?

Negative indices count from the end. -1 = last, -2 = second to last. Java doesn't support negative indexing.