
SLO-based practice chapter: no clean official PCTB book PDF for Class 8 Computer Science was available at build time, so this chapter is built from the PCTB/SNC Student Learning Outcomes (SLOs) for Class 8 Computer Science. It is practice material for the curriculum topics — NOT the official book exercise. When the official book is obtained, its exercise will replace this practice set. Nothing here is presented as a book page or an official question.
Chapter titles follow the PCTB/SNC curriculum progression for this class. All questions and answers below are original practice material written for this guide.
Class 8 computational thinking goes deeper: the same four pillars — decomposition, pattern recognition, abstraction and algorithm design — are now applied to harder problems, such as planning a school event budget or checking a long calculation.
The test of good decomposition is independence: can each part be solved without waiting for the others? If not, split differently.
کلاس 8 میں کمپیوٹیشنل تھنکنگ گہری ہوتی ہے: وہی چار ستون — تجزیہ، نمونوں کی پہچان، تجرید اور الگورتھم کی ترتیب — اب مشکل مسائل پر لگائے جاتے ہیں جیسے اسکول کی تقریب کا بجٹ یا لمبی گنتی کی جانچ۔ اچھی تجزیہ کی پہچان یہ ہے کہ ہر حصہ دوسروں کا انتظار کیے بغیر حل ہو سکے؛ اگر نہیں تو مختلف طریقے سے تقسیم کریں۔
Every algorithm is built from three building blocks: sequence (steps in order), selection (if a condition is true, do this, else do that) and repetition (repeat steps while a condition holds — a loop).
Example — finding the largest of three numbers: compare the first two, keep the larger, compare it with the third, keep the larger. That is sequence plus selection, and it works for any three numbers.
ہر الگورتھم تین بنیادی بلاکوں سے بنتا ہے: ترتیب (مراحل کی ترتیب)، انتخاب (اگر شرط درست ہو تو یہ کرو ورنہ وہ) اور تکرار (شرط قائم رہنے تک مراحل دہراؤ — لوپ)۔ مثال: تین اعداد میں سب سے بڑا ڈھونڈنا — پہلے دو کا موازنہ کریں، بڑا رکھیں، اس کا تیسرے سے موازنہ کریں، بڑا رکھیں۔ یہ ترتیب اور انتخاب ہے اور کسی بھی تین اعداد پر کام کرتا ہے۔
In flowcharts, conditions appear as diamond decisions: is the number even? Is the password correct? Has the end of the list been reached? Each answer sends the flow down a different path.
A loop in a flowchart returns to an earlier step while a condition holds — for example, keep asking for a password until it is correct, but always provide a way out, or the program will loop forever.
فلو چارٹس میں شرائط ہیرے کے فیصلوں کی صورت میں آتی ہیں: کیا عدد جفت ہے؟ کیا پاس ورڈ درست ہے؟ کیا فہرست ختم ہو گئی؟ ہر جواب بہاؤ کو مختلف راستے پر بھیجتا ہے۔ لوپ میں بہاؤ شرط قائم رہنے تک پہلے مرحلے پر واپس جاتا ہے — مثلاً درست ہونے تک پاس ورڈ مانگتے رہو، مگر ہمیشہ نکلنے کا راستہ بھی رکھو ورنہ پروگرام ہمیشہ گھومتا رہے گا۔
A dry run traces an algorithm by hand on sample data, writing each variable's value step by step in a trace table. It finds logic errors before any code exists.
Always test edge cases: zero, the largest allowed value, an empty list, and equal values. Most real bugs hide at the edges, not in the middle. If the dry run fails, fix the algorithm — not the test data.
ڈرائی رن میں الگورتھم کو نمونہ ڈیٹا پر ہاتھ سے چلایا جاتا ہے اور ہر مرحلے پر ہر متغیر کی قدر ٹریس ٹیبل میں لکھی جاتی ہے۔ اس سے کوڈ بننے سے پہلے منطقی غلطیاں مل جاتی ہیں۔ ہمیشہ خاص صورتوں کی جانچ کریں: صفر، سب سے بڑی جائز قدر، خالی فہرست اور برابر قدریں۔ زیادہ تر اصل غلطیاں کناروں پر چھپی ہوتی ہیں، درمیان میں نہیں۔ اگر ڈرائی رن ناکام ہو تو الگورتھم درست کریں، ٹیسٹ ڈیٹا نہیں۔
اس chapter کی exercise SLO-based practice ہے — MCQs, short اور long سوال اس guide کے لیے لکھے گئے ہیں, کتاب کی official exercise نہیں. جواب کے ساتھ practice کرو.
1. Which is the first pillar of computational thinking in practice?
Answer: (b) — Decomposition — breaking a problem into smaller parts — comes first.
2. Sequence, selection and repetition are:
Answer: (b) — Every algorithm is built from sequence, selection and repetition.
3. In a flowchart, a diamond means:
Answer: (c) — The diamond is the decision symbol with yes/no branches.
4. A dry run is:
Answer: (b) — A dry run traces the algorithm by hand, step by step.
5. An edge case is:
Answer: (b) — Edge cases are boundary inputs where bugs most often hide.
6. A loop that never ends is a bug because:
Answer: (b) — A loop must have an exit condition, or the program never finishes.
Answer: Decomposition, pattern recognition, abstraction and algorithm design.
Answer: Selection means choosing between steps based on a condition: if it is true, do this; otherwise, do that.
Answer: A trace table records each variable's value at every step of a dry run, making logic errors visible before any code is written.
Answer: Dividing by zero: the program must handle it (for example show an error) instead of crashing.
Answer: Fix the algorithm — change a step, condition or order — and dry-run again; never change the test data to hide the failure.
Answer: Algorithm: (1) Input A, B, C. (2) Set largest = A. (3) If B > largest, set largest = B. (4) If C > largest, set largest = C. (5) Output largest. Dry run with A=5, B=9, C=7: largest starts 5; B=9 > 5, so largest=9; C=7 is not > 9, so largest stays 9; output 9. Correct.
Answer: Making tea: sequence — boil water, add leaves, pour, wait, serve, in order. Selection — if the guest wants sugar, add sugar, else do not. Repetition — stir while the sugar has not dissolved. Every program, from a game to a bank app, is built from these three blocks combined.
Answer: Most bugs hide at boundaries, not in ordinary cases. For attendance: zero students present, all students present, a student with no record, duplicate entries, and the maximum class size. Testing these proves the program handles real extremes instead of only the easy middle.
Computational thinking in Class 8 means applying decomposition, pattern recognition, abstraction and algorithm design to harder problems, building algorithms from sequence, selection and repetition, and proving them with dry runs and edge-case tests.
Revision guidance: پہلے MCQs خود حل کرو, پھر جواب ملاؤ; short سوالوں کے جواب اپنے الفاظ میں لکھ کر practice کرو; long سوالوں کے لیے ہر section کی headings اور مثالیں یاد رکھو.
کلاس 8 میں کمپیوٹیشنل تھنکنگ کا مطلب تجزیہ، نمونوں کی پہچان، تجرید اور الگورتھم کی ترتیب کو مشکل مسائل پر لگانا، الگورتھم کو ترتیب، انتخاب اور تکرار سے بنانا، اور ڈرائی رن و خاص صورتوں کی جانچ سے ثابت کرنا ہے۔
رہنمائی: پہلے ایم سی کیوز خود حل کریں پھر جوابات ملائیں؛ مختصر سوالات کے جوابات اپنے الفاظ میں لکھ کر مشق کریں؛ تفصیلی سوالات کے لیے ہر سیکشن کی سرخیاں اور مثالیں یاد رکھیں۔
Is chapter ke topics: Computational Thinking Revisited · Algorithms in Detail · Flowcharts and Conditions in Problem Solving · Testing Algorithms: Dry Runs and Edge Cases · مشق
Topics (Urdu): کمپیوٹیشنل تھنکنگ دوبارہ · الگورتھمز تفصیل سے · فلو چارٹس اور مسئلہ حل کرنے میں شرائط · الگورتھمز کی جانچ: ڈرائی رن اور خاص صورتیں
Revision guidance: پہلے MCQs خود حل کرو, پھر جواب ملاؤ; short سوالوں کے جواب اپنے الفاظ میں لکھ کر practice کرو; long سوالوں کے لیے ہر section کی headings اور مثالیں یاد رکھو.
Chapter-wise tests, fresh random papers اور instant score کے لیے PunjabTest.com کا میں test section دیکھو:
PunjabTest.com — Complete Guide Book • Class 8 Computer Science, Chapter 5 (SLO-based practice (not the official book exercise), Session 2026–27) • English + Urdu