Skip to content
Programs · Program 6-7

Q.Program 6-7: Program to print the numbers in a given sequence using for loop.

Punjab PsebTextbookSubjective· 2mImportance★★★★★est
28% · 11/39 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Put the given numbers in a list and iterate over it — for num in sequence: prints 10, 20, 30, 40, 50 in order, without any index arithmetic.

The idea. A for loop iterates over any sequence object. When the data is an arbitrary collection of values (not a regular arithmetic progression that range() could generate), the natural representation is a list, and the loop simply visits its elements in order.

# Program 6-7: print the numbers in a given sequence
sequence = [10, 20, 30, 40, 50]
for num in sequence:
    print(num)

Expected output

10
20
30
40
50

How it works

  • sequence is a list literal holding the given numbers; any values could be stored here — they need not follow a pattern.
  • Each pass of the loop binds num to the next element (first 10, then 20, …) and prints it.
  • The loop ends by itself after the last element, 50. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.