levo

Problem Solving with Programming

Operators, functions and variable scope

  • 3 things to know
  • Paper 2

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.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Computational Thinking
Data
Computers
Networks

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

The check is 45 + 27 = 72.
denarybinaryhexadecimal

Blank Blitz makes facts automatic

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

AA normal test value is 14.
BA boundary test value is 16.
CAn erroneous test value is 20.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

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 traps are the mistakes students actually make.

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.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

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