📑 Table of Contents — किसी भी topic पर सीधे जाएँ
Algorithm व Flowchart — Programming की नींव
🤔 दोनों की ज़रूरत क्यों?
- समस्या को systematic तरीके से हल करने के लिए — सीधे code लिखने पर गलतियाँ ज़्यादा होती हैं।
- Programming logic को पहले से plan व visualize करने के लिए।
- Errors कम होती हैं, debugging आसान बनती है।
- Team में logic communicate करना आसान — flowchart सबको समझ आता है।
📖 Quick Recap — Algorithm की 5 Characteristics
| Characteristic | मतलब |
|---|---|
| Finiteness | सीमित steps में समाप्त हो |
| Definiteness | हर step स्पष्ट व unambiguous |
| Input | 0 या अधिक inputs |
| Output | कम से कम 1 output |
| Effectiveness | हर step simple, manually भी हो सके |
🧮 पहला Example — दो Numbers का Sum
Step 1: Start
Step 2: Read A, B
Step 3: Sum = A + B
Step 4: Display Sum
Step 5: Stop
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
sum = a + b
print("Sum =", sum)⚖️ Algorithm vs Program (नया अंतर!)
| Algorithm | Program |
|---|---|
| Step-by-step logical plan | उसी plan का implementation |
| Language-independent | किसी specific language में (Python) |
| कोई syntax rules नहीं | Syntax व structure अनिवार्य |
| Planning के लिए | Execution के लिए |
Flowchart Symbols — हर आकृति का मतलब
🔣 Complete Symbols Table (7 Symbols)
| Symbol | नाम | उपयोग |
|---|---|---|
| ⬭ Oval | Terminal (Start/End) | Program की शुरुआत व समाप्ति — इसे Terminal Symbol भी कहते हैं |
| ▭ Rectangle | Process | Calculation/operation — जैसे A = B + C |
| ▱ Parallelogram | Input / Output | Data पढ़ना या result दिखाना |
| ◇ Diamond | Decision | Condition की जाँच — Yes/No या True/False branching |
| → Arrow | Flow Line | Program के flow की दिशा |
| ◯ Circle | Connector | Flowchart के दो भागों को जोड़ना (बड़े flowcharts में) |
| 🧾 Document | Print / Report | Output को file/document में print करना |
✔️ Flowchart बनाने के Best Practices
- Start व Stop हमेशा Oval में — दोनों अनिवार्य हैं।
- Flow की दिशा top-to-bottom या left-to-right रखें।
- हर operation Rectangle में, Input/Output Parallelogram में।
- Decision (Diamond) से हमेशा 2 रास्ते — Yes व No, दोनों label करें।
- Arrows एक-दूसरे को cross न करें; flowchart साफ़ व aligned रखें।
🏪 Real-Life Applications
- ATM transaction — PIN check (decision) → balance check → cash निकालना।
- Online shopping — cart → payment → order confirmation का flow।
- Student grading — marks के आधार पर grade (elif ladder)।
- Bank loan approval — eligibility conditions की जाँच।
Sequential Processing — सीधी लाइन में चलना
Flowchart 1: Area of Rectangle (Sequential)
📝 Example 1 — Area of Rectangle
length = float(input("Enter length: "))
breadth = float(input("Enter breadth: "))
area = length * breadth
print("Area of Rectangle =", area)📝 Example 2 — Simple Interest
Flowchart 2: Simple Interest (Sequential)
P = float(input("Enter Principal: "))
R = float(input("Enter Rate of Interest: "))
T = float(input("Enter Time (in years): "))
SI = (P * R * T) / 100
print("Simple Interest =", SI)📝 Example 3 — Temperature Conversion (C → F)
C = float(input("Enter temperature in Celsius: "))
F = (C * 9/5) + 32
print("Temperature in Fahrenheit =", F)📝 Example 4 — तीन Numbers का Average
A = float(input("Enter first number: "))
B = float(input("Enter second number: "))
C = float(input("Enter third number: "))
avg = (A + B + C) / 3
print("Average =", avg)📝 Example 5 — Circle का Area व Circumference
R = float(input("Enter radius of circle: "))
area = 3.14 * R * R
circumference = 2 * 3.14 * R
print("Area =", area)
print("Circumference =", circumference)Circumference = 43.96
Decision Making — Condition के आधार पर रास्ता चुनना
Flowchart 3: Even या Odd? (Decision)
✅ 1. Simple if — केवल True पर चलता है
# Syntax:
# if condition:
# statement
marks = int(input("Enter marks: "))
if marks >= 50:
print("You Passed!")
print("Exam Over.")Exam Over.
✅ 2. if-else — दो रास्ते
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")✅ 3. Nested if — if के अंदर if
marks = int(input("Enter marks: "))
if marks >= 40:
if marks >= 75:
print("Distinction")
else:
print("Pass")
else:
print("Fail")✅ 4. if-elif-else Ladder — कई conditions की सीढ़ी
marks = int(input("Enter marks: "))
if marks >= 90:
print("Grade A+")
elif marks >= 75:
print("Grade A")
elif marks >= 60:
print("Grade B")
elif marks >= 40:
print("Grade C")
else:
print("Fail")⚡ Real-Life Example — Electricity Bill
units = int(input("Enter electricity units used: "))
if units <= 100:
bill = units * 5
elif units <= 200:
bill = units * 7
else:
bill = units * 10
print("Total Bill = Rs.", bill)Looping (Iteration) — बार-बार दोहराना
Flowchart 4: Sum of 1 to N (Loop)
✅ 1. while Loop — जब तक condition True
# Syntax:
# while condition:
# statements
i = 1
while i <= 5:
print(i)
i += 1
print("Loop Finished")2
3
4
5
Loop Finished
✅ 2. for Loop — जब repetitions पता हों
# Syntax:
# for variable in sequence:
# statements
for i in range(1, 6):
print(i, end=" ")
print("\nLoop Complete")Loop Complete
✅ 3. Sum of First N Natural Numbers
n = int(input("Enter N: "))
sum = 0
i = 1
while i <= n:
sum += i
i += 1
print("Sum =", sum)✅ 4. Nested Loop — Loop के अंदर Loop
for i in range(1, 4): # Outer loop
for j in range(1, 4): # Inner loop
print(i, j)1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
⚖️ while vs for — कब कौन-सा?
| Feature | while Loop | for Loop |
|---|---|---|
| Use Case | Repetitions की संख्या पता न हो | संख्या पता हो |
| Condition | हर बार manually check | range() खुद संभालता है |
| Initialization | Loop से पहले manually | range() के अंदर |
| Example | सही password आने तक पूछना | 1 से 10 तक print, list पर चलना |
Loop Control Statements — break, continue, pass
🛑 break — Loop को तुरंत समाप्त
for i in range(1, 10):
if i == 6:
break
print(i, end=" ")⏭️ continue — यह iteration छोड़ो, आगे बढ़ो
for i in range(1, 6):
if i == 3:
continue
print(i, end=" ")⬜ pass — कुछ नहीं करता (Placeholder)
for i in range(1, 4):
if i == 2:
pass # baad me code likhenge
print(i, end=" ")← pass ने कुछ नहीं बदला — सब print हुए।
Common Solved Examples — Exam के 10 पक्के Programs
Example 1 — दो Numbers को Swap करना (3rd Variable से)
Flowchart 5: Swap Two Numbers (temp variable)
A = int(input("Enter A: "))
B = int(input("Enter B: "))
temp = A
A = B
B = temp
print("After swap: A =", A, ", B =", B)
# Python ka shortcut (bina temp ke):
# A, B = B, AExample 2 — Maximum of Two Numbers
A = int(input("Enter first number: "))
B = int(input("Enter second number: "))
if A > B:
print("A is greater")
else:
print("B is greater")Example 3 — Factorial of a Number
Flowchart 6: Factorial (Loop with backward arrow)
N = int(input("Enter a number: "))
Fact = 1
i = 1
while i <= N:
Fact = Fact * i
i += 1
print("Factorial =", Fact)Example 4 — Reverse a Number
Flowchart 7: Reverse a Number (Loop)
N = int(input("Enter a number: "))
Rev = 0
while N > 0:
R = N % 10 # aakhri digit
Rev = Rev * 10 + R
N = N // 10 # aakhri digit hatao
print("Reversed Number =", Rev)Example 5 — Palindrome Number Check
Flowchart 8: Palindrome Check (Loop + Decision)
N = int(input("Enter a number: "))
copy = N
rev = 0
while N > 0:
r = N % 10
rev = rev * 10 + r
N = N // 10
if copy == rev:
print("Palindrome Number")
else:
print("Not Palindrome")Example 6 — Prime Number Check
Flowchart 9: Prime Number Check
N = int(input("Enter number: "))
is_prime = True
if N < 2:
is_prime = False
for i in range(2, N):
if N % i == 0:
is_prime = False
break
if is_prime:
print(N, "is Prime")
else:
print(N, "is Not Prime")Example 7 — Fibonacci Series
n = int(input("Kitne terms? "))
a, b = 0, 1
for i in range(n):
print(a, end=" ")
a, b = b, a + bExample 8 — Student Grade Evaluation
marks = int(input("Enter marks: "))
if marks >= 90:
grade = "A+"
elif marks >= 75:
grade = "A"
elif marks >= 60:
grade = "B"
elif marks >= 40:
grade = "C"
else:
grade = "Fail"
print("Grade:", grade)Example 9 — Smallest of Three Numbers
Flowchart 10: Smallest of Three Numbers (Nested Decision)
A = int(input("Enter first: "))
B = int(input("Enter second: "))
C = int(input("Enter third: "))
if A < B and A < C:
smallest = A
elif B < C:
smallest = B
else:
smallest = C
print("Smallest number =", smallest)Example 10 — Decimal to Binary Conversion
N = int(input("Enter decimal number: "))
binary = ""
if N == 0:
binary = "0"
while N > 0:
binary = str(N % 2) + binary
N = N // 2
print("Binary =", binary)← Check: 8+4+0+1 = 13 ✓
🎯 Output-Based Questions — पहले सोचो, फिर देखो!
Q1. Range का खेल
for i in range(2, 12, 3):
print(i, end=" ")← range(start, stop, step): 2 से शुरू, 3-3 बढ़ते हुए, 12 से पहले तक।
Q2. while का Trace
x = 20
while x > 5:
print(x, end=" ")
x = x // 2← x: 20 (print) → 10 (print) → 5 पर condition false (5 > 5 नहीं), रुक गया।
Q3. break की position
for i in range(1, 8):
print(i, end=" ")
if i == 4:
break← print पहले है, break बाद में — इसलिए 4 print होकर loop टूटा। (अगर break पहले होता तो 1 2 3 आता!)
Q4. continue vs break
for i in range(1, 6):
if i % 2 == 0:
continue
print(i, end=" ")← Even numbers (2, 4) पर continue चला — print skip; सिर्फ odd print हुए।
Q5. elif Ladder Trace
x = 85
if x >= 90:
print("A+")
elif x >= 80:
print("A")
elif x >= 70:
print("B")
else:
print("C")← 85 ≥ 90 false; 85 ≥ 80 true → "A" print, बाकी ladder skip (85 ≥ 70 भी true था, पर बारी नहीं आई)।
Q6. Nested Loop की गिनती
for i in range(3):
for j in range(4):
print("*", end="")
print()****
****
← 3 × 4 = 12 stars, हर row में 4 (inner), 3 rows (outer)।
Q7. Loop के बाद Variable की Value
s = 0
for i in range(1, 5):
s = s + i
print(s)← s = 1+2+3+4 = 10 (range में 5 शामिल नहीं)। print loop के बाहर है — सिर्फ final value छपी।
Q8. Reverse Logic Trace
n = 123
rev = 0
while n > 0:
rev = rev * 10 + n % 10
n = n // 10
print(rev)← Trace: rev=3, n=12 → rev=32, n=1 → rev=321, n=0 → रुका।
Q9. Infinite Loop पहचानिए
i = 1
while i <= 5:
print(i)← i += 1 नहीं लिखा — condition हमेशा true, यह Infinite Loop है।
Q10. Nested if का रास्ता
a = 10
b = 20
if a > 5:
if b > 25:
print("Both big")
else:
print("Only a big")
else:
print("a small")← बाहरी if true (10 > 5) → भीतरी if false (20 > 25 नहीं) → भीतरी else चला।
Q11. Step वाली range उल्टी
for i in range(10, 0, -2):
print(i, end=" ")← Negative step = उल्टी गिनती; 0 शामिल नहीं।
Q12. Swap without Temp
a, b = 7, 3 a, b = b, a + b print(a, b)
← दाईं ओर पहले evaluate होता है (b=3, a+b=10), फिर एक साथ assign — a=3, b=10। यह simple swap नहीं है, ध्यान से!
💻 Practice Programs — खुद Try कीजिए
Program 1 — Sum of Digits
n = int(input("Enter number: "))
total = 0
while n > 0:
total += n % 10
n = n // 10
print("Sum of digits =", total)Program 2 — Armstrong Number Check (153 = 1³+5³+3³)
n = int(input("Enter 3-digit number: "))
temp = n
total = 0
while temp > 0:
d = temp % 10
total += d ** 3
temp = temp // 10
if total == n:
print(n, "is an Armstrong number")
else:
print(n, "is NOT an Armstrong number")Program 3 — Star Pattern (Right Triangle)
n = int(input("Enter rows: "))
for i in range(1, n + 1):
print("*" * i)**
***
****
Program 4 — HCF (GCD) of Two Numbers
a = int(input("Enter first: "))
b = int(input("Enter second: "))
hcf = 1
for i in range(1, min(a, b) + 1):
if a % i == 0 and b % i == 0:
hcf = i
print("HCF =", hcf)Program 5 — Count Even/Odd in N Numbers
n = int(input("Kitne numbers? "))
even = odd = 0
for i in range(n):
num = int(input("Number: "))
if num % 2 == 0:
even += 1
else:
odd += 1
print("Even count =", even)
print("Odd count =", odd)Odd count = 2
Program 6 — Multiplication Table (Loop से)
num = int(input("Enter a number: "))
for i in range(1, 11):
print(num, "x", i, "=", num * i)9 x 2 = 18
...
9 x 10 = 90
Program 7 — Leap Year Check
year = int(input("Enter year: "))
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print(year, "is a Leap Year")
else:
print(year, "is NOT a Leap Year")Program 8 — ATM PIN Retry (3 Attempts)
correct_pin = 1234
attempts = 0
while attempts < 3:
pin = int(input("Enter PIN: "))
if pin == correct_pin:
print("Access Granted!")
break
attempts += 1
print("Wrong PIN! Attempts left:", 3 - attempts)
else:
print("Card Blocked!")Wrong PIN! Attempts left: 1
Access Granted!
Summary — Quick Revision (Exam से पहले पढ़ें)
- Algorithm = written plan (text steps); Flowchart = visual plan (symbols); Program = implementation।
- Symbols: Oval = Start/Stop; Rectangle = Process; Parallelogram = I/O; Diamond = Decision; Circle = Connector।
- Sequential = ऊपर से नीचे सीधा flow (Area, SI, Average); Decision = condition से रास्ता (if-else); Iterative = repetition (loops)।
- if = 1 condition; if-else = 2-way; if-elif-else = multi-way (पहली true चलती है); nested if = level-wise checking।
- while = unknown repetitions (condition-based); for = known repetitions (range-based); range(1, 6) में 6 शामिल नहीं।
- break = loop समाप्त; continue = iteration skip; pass = कुछ नहीं (placeholder)।
- Nested loop की total iterations = outer × inner; counter न बढ़ाने पर infinite loop।
- याद रखने वाले programs: Swap (temp से), Factorial, Reverse (%10 व //10), Palindrome, Prime, Fibonacci, Armstrong, HCF, Leap Year।
Model Questions — 50 MCQs + 15 Theory Questions
❓ A. Multiple Choice Questions (50)
| # | प्रश्न व उत्तर |
|---|---|
| 1 | Algorithm है — (a) Diagram(b) Step-by-step written procedure(c) Language(d) Software ✔ सही उत्तर: (b) Step-by-step written procedure |
| 2 | Flowchart है — (a) Algorithm का graphical रूप(b) Program(c) Compiler(d) Data ✔ सही उत्तर: (a) Algorithm का graphical रूप |
| 3 | Algorithm व Flowchart में पहले बनता है — (a) Flowchart(b) Algorithm(c) Code(d) कोई भी ✔ सही उत्तर: (b) Algorithmपहले plan, फिर diagram। |
| 4 | Algorithm होता है — (a) Language-dependent(b) Language-independent(c) Python-only(d) Binary ✔ सही उत्तर: (b) Language-independent |
| 5 | Start/Stop के लिए flowchart symbol — (a) Rectangle(b) Diamond(c) Oval(d) Circle ✔ सही उत्तर: (c) OvalTerminal symbol। |
| 6 | Oval symbol का दूसरा नाम है — (a) Process(b) Terminal(c) Connector(d) Decision ✔ सही उत्तर: (b) Terminal |
| 7 | Process (calculation) के लिए symbol — (a) Rectangle(b) Oval(c) Diamond(d) Parallelogram ✔ सही उत्तर: (a) Rectangle |
| 8 | Input/Output के लिए symbol — (a) Diamond(b) Circle(c) Parallelogram(d) Oval ✔ सही उत्तर: (c) Parallelogram |
| 9 | Decision के लिए symbol — (a) Diamond(b) Rectangle(c) Arrow(d) Oval ✔ सही उत्तर: (a) Diamond |
| 10 | Flowchart के दो भागों को जोड़ता है — (a) Arrow(b) Connector (Circle)(c) Diamond(d) Document ✔ सही उत्तर: (b) Connector (Circle) |
| 11 | Flow की दिशा दिखाता है — (a) Oval(b) Rectangle(c) Arrow(d) Circle ✔ सही उत्तर: (c) Arrow (Flow Line) |
| 12 | Decision symbol से कितने रास्ते निकलते हैं? (a) 1(b) 2(c) 3(d) 0 ✔ सही उत्तर: (b) 2Yes व No। |
| 13 | हर flowchart में अनिवार्य हैं — (a) Loop(b) Start व Stop(c) Decision(d) Connector ✔ सही उत्तर: (b) Start व Stop |
| 14 | Flowchart की दिशा होनी चाहिए — (a) Bottom-to-top(b) Top-to-bottom / Left-to-right(c) Random(d) Circular ✔ सही उत्तर: (b) Top-to-bottom / Left-to-right |
| 15 | A = B + C flowchart में लिखा जाएगा — (a) Oval में(b) Diamond में(c) Rectangle में(d) Circle में ✔ सही उत्तर: (c) Rectangle मेंयह process है। |
| 16 | Statements का एक के बाद एक क्रम से चलना — (a) Decision(b) Sequential Processing(c) Iteration(d) Branching ✔ सही उत्तर: (b) Sequential Processing |
| 17 | Sequential structure में नहीं होता — (a) Input(b) Output(c) Branching/Looping(d) Process ✔ सही उत्तर: (c) Branching/Looping |
| 18 | Simple Interest formula है — (a) P×R×T(b) (P×R×T)/100(c) P+R+T(d) (P+R)/T ✔ सही उत्तर: (b) (P×R×T)/100 |
| 19 | Celsius से Fahrenheit का formula — (a) C×5/9+32(b) (C×9/5)+32(c) C+32(d) C×9/5−32 ✔ सही उत्तर: (b) (C×9/5)+32 |
| 20 | Condition के आधार पर रास्ता चुनना कहलाता है — (a) Sequence(b) Decision Making / Selection(c) Iteration(d) Recursion ✔ सही उत्तर: (b) Decision Making / Selection |
| 21 | Python में decision के लिए उपयोग होता है — (a) loop(b) if, elif, else(c) def(d) import ✔ सही उत्तर: (b) if, elif, else |
| 22 | if-elif-else ladder में execute होती है — (a) सभी true conditions(b) केवल पहली true condition(c) आखिरी condition(d) else हमेशा ✔ सही उत्तर: (b) केवल पहली true condition |
| 23 | एक if के अंदर दूसरा if — (a) Ladder(b) Nested if(c) Loop(d) Chain ✔ सही उत्तर: (b) Nested if |
| 24 | num % 2 == 0 check करता है — (a) Prime(b) Even(c) Positive(d) Palindrome ✔ सही उत्तर: (b) Even |
| 25 | if marks >= 50: print("Pass") — marks = 40 पर output — (a) Pass(b) Fail(c) कुछ नहीं(d) Error ✔ सही उत्तर: (c) कुछ नहींcondition false, else भी नहीं है। |
| 26 | बार-बार दोहराई जाने वाली प्रक्रिया — (a) Sequence(b) Selection(c) Iteration/Looping(d) Declaration ✔ सही उत्तर: (c) Iteration/Looping |
| 27 | Python में कितने मुख्य loops हैं? (a) 1(b) 2 (while, for)(c) 4(d) 5 ✔ सही उत्तर: (b) 2 (while, for) |
| 28 | Repetitions की संख्या पता न हो तो उपयोग करें — (a) for(b) while(c) if(d) pass ✔ सही उत्तर: (b) while |
| 29 | range(1, 6) देगा — (a) 1 से 6(b) 1 से 5(c) 0 से 6(d) 2 से 6 ✔ सही उत्तर: (b) 1 से 5stop शामिल नहीं। |
| 30 | range(10, 0, -2) देगा — (a) 10 8 6 4 2(b) 10 से 0(c) Error(d) 2 4 6 8 10 ✔ सही उत्तर: (a) 10 8 6 4 2 |
| 31 | Loop को बीच में समाप्त करता है — (a) continue(b) pass(c) break(d) stop ✔ सही उत्तर: (c) break |
| 32 | Current iteration को skip करता है — (a) break(b) continue(c) pass(d) exit ✔ सही उत्तर: (b) continue |
| 33 | कुछ न करने वाला placeholder statement — (a) break(b) continue(c) pass(d) null ✔ सही उत्तर: (c) pass |
| 34 | Counter न बढ़ाने पर while loop बन जाता है — (a) for loop(b) Infinite loop(c) Nested loop(d) Dead loop ✔ सही उत्तर: (b) Infinite loop |
| 35 | Nested loop (outer 3, inner 4) में inner body कुल कितनी बार चलेगी? (a) 7(b) 12(c) 3(d) 4 ✔ सही उत्तर: (b) 123 × 4। |
| 36 | Flowchart में loop दिखाने के लिए चाहिए — (a) दो Ovals(b) Decision + backward arrow(c) केवल Rectangle(d) Connector ✔ सही उत्तर: (b) Decision + backward arrow |
| 37 | for i in range(1,10): if i==6: break — print(i) पहले हो तो output — (a) 1-5(b) 1-6(c) 1-9(d) 6 ✔ सही उत्तर: (b) 1 2 3 4 5 6print पहले, break बाद में। |
| 38 | Swapping में temp variable का काम — (a) जोड़ना(b) एक value सुरक्षित रखना(c) घटाना(d) print करना ✔ सही उत्तर: (b) एक value सुरक्षित रखना |
| 39 | Python में बिना temp के swap — (a) a,b = b,a(b) a=b(c) swap(a,b)(d) असंभव ✔ सही उत्तर: (a) a, b = b, a |
| 40 | 5 का factorial है — (a) 25(b) 120(c) 60(d) 100 ✔ सही उत्तर: (b) 1201×2×3×4×5। |
| 41 | Number का आखिरी digit निकालने के लिए — (a) N // 10(b) N % 10(c) N * 10(d) N + 10 ✔ सही उत्तर: (b) N % 10 |
| 42 | Number से आखिरी digit हटाने के लिए — (a) N % 10(b) N // 10(c) N - 10(d) N / 2 ✔ सही उत्तर: (b) N // 10 |
| 43 | जो number उल्टा करने पर same रहे — (a) Prime(b) Armstrong(c) Palindrome(d) Perfect ✔ सही उत्तर: (c) Palindromeजैसे 121, 1331। |
| 44 | 153 है — (a) Prime(b) Armstrong number(c) Palindrome(d) Even ✔ सही उत्तर: (b) Armstrong1³+5³+3³ = 153। |
| 45 | Fibonacci series का अगला term: 0 1 1 2 3 5 8 ? (a) 11(b) 13(c) 10(d) 16 ✔ सही उत्तर: (b) 135 + 8। |
| 46 | Prime check में loop चलता है — (a) 2 से N-1(b) 0 से N(c) 1 से N(d) N से 1 ✔ सही उत्तर: (a) 2 से N-1कहीं divide हुआ तो prime नहीं। |
| 47 | Leap year condition है — (a) year % 4 == 0 only(b) (div by 4 AND not by 100) OR div by 400(c) year % 100 == 0(d) year % 2 == 0 ✔ सही उत्तर: (b)इसीलिए 1900 leap नहीं, 2000 है। |
| 48 | x=20; while x>5: print(x); x = x//2 — output — (a) 20 10(b) 20 10 5(c) 20(d) Infinite ✔ सही उत्तर: (a) 20 105 पर condition false। |
| 49 | ATM PIN 3-attempts logic में उपयोग होता है — (a) केवल if(b) loop + break(c) केवल print(d) pass ✔ सही उत्तर: (b) loop + break |
| 50 | Algorithm और Program में अंतर — (a) दोनों same(b) Algorithm plan है, Program implementation(c) Program पहले बनता है(d) Algorithm में syntax होता है ✔ सही उत्तर: (b) Algorithm plan, Program implementation |
📝 B. 15 Theory Questions (Short Answers)
- Algorithm और Flowchart में अंतर बताइए।Algorithm text/steps में लिखा plan है (language-independent, बनाना आसान); Flowchart उन्हीं steps का symbols वाला diagram है (देखते ही समझ आता है, पर redraw कठिन)।
- Flowchart के 7 symbols व उनके उपयोग लिखिए।Oval = Start/Stop (Terminal); Rectangle = Process; Parallelogram = Input/Output; Diamond = Decision; Arrow = Flow line; Circle = Connector; Document = Print/Report।
- Sequential Processing क्या है? उदाहरण दीजिए।Statements का एक के बाद एक, ऊपर से नीचे क्रम से चलना — बिना branching/looping के। जैसे Area of Rectangle, Simple Interest, Average निकालना।
- Decision Making क्या है? Python में इसके types बताइए।Condition के आधार पर अलग-अलग रास्तों पर जाना। Types — simple if, if-else, nested if, if-elif-else ladder।
- if-elif-else ladder कैसे काम करती है?Conditions ऊपर से नीचे check होती हैं — जो पहली true मिली उसका block execute होकर बाकी सब skip; कोई true न हो तो else चलता है।
- Nested if किसे कहते हैं? कब उपयोग होता है?एक if के अंदर दूसरा if। जब multi-level checking करनी हो — जैसे पहले pass/fail check, फिर pass के अंदर distinction check।
- while और for loop में अंतर बताइए।while = condition-based, repetitions unknown, initialization/increment manually; for = sequence/range-based, repetitions known, सब range() संभालता है।
- break, continue और pass का अंतर उदाहरण सहित लिखिए।break loop को पूरा समाप्त करता है; continue current iteration skip करके अगले पर जाता है; pass कुछ नहीं करता (placeholder)। range(1,6) में i==3 पर continue से output 1 2 4 5।
- Infinite loop क्या है? कैसे बचें?ऐसा loop जो कभी नहीं रुकता — condition कभी false नहीं होती (counter बढ़ाना भूलने पर)। बचाव: loop में counter update व सही condition ज़रूर रखें।
- Nested loop क्या है? Total iterations कैसे निकालते हैं?Loop के अंदर loop। हर outer iteration पर inner पूरा चलता है — total = outer × inner (जैसे 3 × 4 = 12)।
- दो variables swap करने का algorithm लिखिए।Start → Input A, B → temp = A → A = B → B = temp → Print A, B → Stop। (Python shortcut: a, b = b, a)
- Number reverse करने की logic समझाइए।जब तक N > 0: N % 10 से आखिरी digit निकालो, rev = rev × 10 + digit से जोड़ो, N = N // 10 से digit हटाओ। 123 → 321।
- Palindrome number की जाँच कैसे होती है?Number की copy रखो, उसे reverse करो — अगर copy == reverse तो Palindrome (जैसे 121, 1331), वरना नहीं।
- Prime number check का algorithm लिखिए।Input N → अगर N < 2 तो prime नहीं → 2 से N-1 तक divide करके देखो → कहीं भी remainder 0 आया तो prime नहीं (break), वरना Prime।
- Leap year की condition समझाइए।(Year 4 से divisible AND 100 से नहीं) OR (400 से divisible)। इसलिए 2024 व 2000 leap हैं, पर 1900 नहीं (100 से divisible, 400 से नहीं)।