levo

Problem Solving with Programming

Operators, functions and variable scope

  • 3 things to know
  • Paper 2
Start revising · £5/month

Overview

%, // and ** with worked results, comparisons and logical operators, functions and procedures, parameters, built-in and library subprograms, and local and global variables.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What is printed by print(23 % 4) and then print(23 // 4)?

Key term

What is printed by secs = 200, then print(str(secs // 60) + " min " + str(secs % 60) + " s")?

Numbers

State what is printed by print(2 ** 10).

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is printed by print(23 % 4) and then print(23 // 4)?

    Model answer

    The first line prints 3 and the second prints 5. The check is 5 × 4 + 3 = 23.

  2. 2

    What is printed by secs = 200, then print(str(secs // 60) + " min " + str(secs % 60) + " s")?

    Model answer

    The code prints 3 min 20 s. The // operator gives the whole minutes and % gives the seconds left over.

  3. 3

    State what is printed by print(2 ** 10).

    Model answer

    The code prints 1024. The ** operator raises 2 to the power 10.

  4. 4

    What is printed by n = 14, then print(n % 2 == 0)?

    Model answer

    The code prints True. The remainder when 14 is divided by 2 is 0, so the number is even.

  5. 5

    What is printed by print(2 + 3 * 4 ** 2)?

    Model answer

    The code prints 50. The power is worked first to give 16, then 3 × 16 = 48, then 2 is added.

  6. 6

    What is printed by a = "apple", b = "Apple", then print(a == b)?

    Model answer

    The code prints False. Comparison of strings is case-sensitive, so a lower-case a and a capital A differ.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Computational Thinking
Data
Computers
Networks

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

The check is 45 + 27 = 72.
denarybinaryhexadecimal

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

A kibibyte (KiB) is 1,024 bytes. The figure 1,024 is 2¹⁰.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Problem Solving with Programming, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.