SHS Computing · Year 1

Programming Basics in Python practice questions

Python as a high-level language and IDEs, print and input, the assignment, arithmetic and comparison operators, string concatenation and f-strings, the input-process-output model, the swap algorithm, if/else decisions, and built-in list methods such as len, count, index, sort, reverse and copy.

23 questions in this topic: 1 recall, 5 applying skills and concepts, 14 strategic thinking and 3 extended thinking. Every one carries a written explanation.

Sample questions

3 of 23 questions in this topic. Sign up to answer them and see the explanations.

  1. Question 1Extended thinking

    A program must swap the first and last elements of a list subjects = ["Maths", "English", "Computing"]. Which code does this for a list of any length?

    • asubjects[0] = subjects[-1]; subjects[-1] = subjects[0]
    • bsubjects.reverse()
    • csubjects[0], subjects[-1] = subjects[-1], subjects[0]
    • dsubjects[1], subjects[3] = subjects[3], subjects[1]
  2. Question 2Extended thinking

    A shop gives 10% off trousers and 5% off a jacket. A program reads trousers = 200 and jacket = 400, then prints the total paid. Which line computes it correctly?

    • atotal = (trousers + jacket) * 0.85
    • btotal = trousers * 0.9 + jacket * 0.95
    • ctotal = trousers * 0.1 + jacket * 0.05
    • dtotal = (trousers + jacket) * 0.925
  3. Question 3Extended thinking

    A learner tries to swap two values with: a = 49; b = 61; temp = a; b = a; b = temp; print(a, b). What does it print, and why?

    • a61 49, because the temporary variable correctly swaps the two values over safely
    • b49 49, because b is overwritten with a's value and a never receives b's value
    • c49 61, because the variables cannot change once they have been given values
    • d61 61, because temp takes the value of b before a is overwritten by it

Answer these and 20 more on Programming Basics in Python

Free account. Instant marking, a written explanation for every question.

Start practising free

More Computing Year 1 topics

All Computing topics