AmbifulWorksheets
Cheat sheet
CBSE · Class 6 · Computational Thinking and AI

Loops and Conditions

A loop repeats steps; a condition (if–otherwise) chooses which step to do. Tracing a loop means tracking the values round by round.

Key ideas

Remember

Count from a to b in steps of s(last number said − a) ÷ s + 1
x = a, repeat k times: x = x + dx = a + k × d
x = a, repeat k times: x = x × 2x = a × 2ᵏ
Repeat a times (repeat b times: clap)a × b claps
Turn for a regular shape with n sides360° ÷ n (square: 90°, hexagon: 60°)
While the box has less than ₹T, add ₹dstop at the first total of ₹T or more

Watch out

Worked example

(a) Start with n = 18.
While n is 84 or less: say n, then add 4 to n.
How many numbers are said?
(b) Isha's box has ₹30.
While the box has less than ₹745: add ₹50 and count one day.
How many days are counted?

Working: (a) 18, 22, …, 82: (82 − 18) ÷ 4 + 1 = 17; (b) ₹30 + 15 × ₹50 = ₹780, which is the first total of ₹745 or more

Answer: (a) 17; (b) 15