Edexcel GCSE Computer Science 1CP2
Computational Thinking
Data
Computers
Networks
Issues and Impact
Problem Solving with Programming
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.
What is printed by secs = 200, then print(str(secs // 60) + " min " + str(secs % 60) + " s")?
State what is printed by print(2 ** 10).
Questions from this subtopic
Each one with the model answer underneath.
- 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
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
State what is printed by print(2 ** 10).
Model answer
The code prints 1024. The ** operator raises 2 to the power 10.
- 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
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
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.
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.