📑 Table of Contents — किसी भी topic पर सीधे जाएँ
Programming Languages — Computer से बात करने का माध्यम
🤔 Programming Language की ज़रूरत क्यों?
- Computer केवल binary language (0 और 1) समझता है — इसे machine language कहते हैं।
- मनुष्य के लिए binary में लिखना लगभग असंभव है (कल्पना कीजिए — "Hello" print करने के लिए हज़ारों 0/1!)।
- Programming languages instructions को human-readable (English जैसा) बनाती हैं।
- फिर Compiler या Interpreter उन्हें machine code में translate कर देता है।
🧬 Languages की 5 Generations (Evolution)
Machine Language से AI Languages तक का सफ़र
1️⃣ Machine Language (1st Generation)
सबसे नीचले स्तर (lowest level) की भाषा — instructions केवल 0 और 1 में। यह hardware द्वारा सीधे समझी जाती है, कोई translation नहीं चाहिए।
10110100 00001111 // yah kisi CPU instruction ka binary roop hai // jaise "register me value load karo"
2️⃣ Assembly Language (2nd Generation)
Machine language की readability बढ़ाने के लिए mnemonics (छोटे English words) आए — जैसे MOV (move), ADD (जोड़ो), SUB (घटाओ)। इसे machine code में बदलने के लिए Assembler चाहिए।
MOV A, 05H ; Register A me 5 daalo MOV B, 06H ; Register B me 6 daalo ADD A, B ; A = A + B (yaani 11)
3️⃣ High-Level Languages (3rd Generation)
मनुष्यों के लिए आसान — syntax English जैसा। Compiler/Interpreter translate करता है। Python, C, C++, Java, BASIC इसी category में हैं।
a = 5
b = 10
sum = a + b
print("Sum =", sum)4️⃣ Fourth Generation Languages (4GL)
और भी high-level — आप बताते हैं "क्या चाहिए", यह नहीं कि "कैसे करना है"। SQL, MATLAB, R जैसे। उद्देश्य: programming effort कम करना।
SELECT name, age FROM students WHERE age > 18; -- humne sirf bataya KYA chahiye, -- HOW (loop/compare) database khud karega
5️⃣ Fifth Generation Languages (5GL)
Logic-based व AI-oriented languages — Machine Learning, Artificial Intelligence व Expert Systems में उपयोग। उदाहरण: Prolog, Mercury और Python के AI frameworks (TensorFlow आदि)।
🧠 Key Programming Concepts (Exam में पूछे जाते हैं)
| Term | मतलब |
|---|---|
| Source Code | Programmer द्वारा लिखा high-level code (जैसे .py file) |
| Object Code | Machine-readable translated version |
| Executable Code | Final file जो directly run होती है (जैसे .exe) |
| Syntax | Language के grammatical rules (लिखने का सही तरीका) |
| Semantics | Code का meaning या behavior (क्या करेगा) |
🚀 Python ही क्यों? (M3-R5 की language)
- Simple, readable syntax — beginners के लिए सबसे आसान।
- Interpreter-based — code लिखो और तुरंत run करो, compile step नहीं।
- Free, open source व platform-independent — Windows/Mac/Linux सबपर।
- Huge libraries — Data Science, AI, Web Development सबके लिए ready-made।
- O Level syllabus के practical implementation के लिए perfect।
Compiler vs Interpreter — Translation के दो तरीके
⚖️ Master Comparison Table
| Feature | Compiler | Interpreter |
|---|---|---|
| Translation | पूरे program को एक बार में translate करता है | एक-एक line translate व execute करता है |
| Execution Speed | Fast (pre-compiled) | Slow (line-by-line) |
| Error Detection | सभी errors compile time पर एक साथ दिखते हैं | पहली error पर execution रुक जाता है |
| Object Code | बनता है (save होता है) | नहीं बनता |
| Memory | ज़्यादा (object code store) | कम |
| Example Languages | C, C++ | Python, JavaScript |
print("Hello, World!")gcc program.c से compile करना पड़ता, फिर run करते।Basic Model of Computation — Computer सोचता कैसे है?
📘 Computational Models के 3 Types
- 1. Mathematical Model: Computation को equations व logic में दर्शाता है।
- 2. Physical Model: बताता है CPU, Memory व Storage computation को वास्तव में कैसे चलाते हैं।
- 3. Abstract Model: Logical steps व data flow पर केंद्रित — जैसे Turing Machine व RAM Model।
1️⃣ Turing Machine — Theory का बादशाह
Alan Turing (father of computer science) द्वारा दिया गया theoretical model। इसके 3 parts:
- Infinite Tape: जिस पर symbols लिखे जाते हैं (memory की तरह)।
- Head: जो symbols को पढ़ता और लिखता है।
- Control Unit: जो next step तय करती है।
x = 2 # Step 1: memory me 2 rakha y = 3 # Step 2: memory me 3 rakha z = x + y # Step 3: dono padhe, joda, result rakha print(z) # Step 4: result dikhaya
2️⃣ Finite Automata (FA) — Limited Memory वाला Model
Input symbols को पढ़कर states बदलता है और final state तक पहुँचता है। Pattern matching में उपयोग होता है।
- DFA (Deterministic FA): हर symbol के लिए केवल एक next state।
- NFA (Non-Deterministic FA): एक symbol के लिए कई possible states।
s = "10101"
if "101" in s:
print("Pattern found!")
else:
print("Pattern not found!")3️⃣ RAM Model (Random Access Machine) — Practice का Model
Computation का practical रूप — जैसा असली computers में होता है:
- हर instruction को 1 unit time माना जाता है।
- Memory access O(1) time में (किसी भी location पर सीधे पहुँच)।
- Algorithm analysis के लिए सबसे उपयुक्त model।
arr = [10, 20, 30, 40] arr[2] = arr[2] + 5 # index 2 par SEEDHE pahunche (koi loop nahi) print(arr)
⚙️ Computational Model के 5 Components
| Component | काम | Python में |
|---|---|---|
| Input | Raw data | input(), variables |
| Process | Operations व logic | Calculations, loops |
| Output | Final result | print() |
| Storage | Temporary/permanent memory | Variables, lists |
| Control Unit | Execution order manage करना | Interpreter |
num = int(input("Enter a number: ")) # INPUT
square = num * num # PROCESS
print("Square is:", square) # OUTPUTAlgorithms — समस्या हल करने के Steps
⭐ Algorithm की 5 Characteristics (बहुत Important)
| Characteristic | मतलब |
|---|---|
| 1. Finiteness | Finite steps के बाद खत्म ज़रूर हो (अनंत नहीं चले) |
| 2. Definiteness | हर step बिल्कुल clear व unambiguous हो |
| 3. Input | 0 या अधिक inputs हों |
| 4. Output | कम से कम 1 output ज़रूर हो |
| 5. Effectiveness | हर step इतना simple हो कि practically किया जा सके |
📝 Example 1 — दो Numbers का Sum
Step 1: Start
Step 2: Input A और B
Step 3: Sum = A + B
Step 4: Print Sum
Step 5: Stop
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
sum = a + b
print("Sum =", sum)📝 Example 2 — दो Numbers में बड़ा (Largest of Two)
Step 1: Start
Step 2: Input A, B
Step 3: यदि A > B है तो Print A
Step 4: वरना Print B
Step 5: Stop
a = int(input("Enter A: "))
b = int(input("Enter B: "))
if a > b:
print("Largest =", a)
else:
print("Largest =", b)📝 Example 3 — Even या Odd
Step 1: Start
Step 2: Input N
Step 3: यदि N % 2 == 0 → Print "Even"
Step 4: वरना → Print "Odd"
Step 5: Stop
n = int(input("Enter number: "))
if n % 2 == 0:
print(n, "is Even")
else:
print(n, "is Odd")🧩 Algorithms के Types
| Type | क्या करता है | Example |
|---|---|---|
| Sequential | Steps सीधे क्रम में | Sum of two numbers |
| Conditional (Selection) | Condition के आधार पर रास्ता चुनना | Largest of two, Even/Odd |
| Iterative (Loop) | Steps बार-बार दोहराना | 1 से 10 तक print, Factorial |
| Recursive | Function खुद को call करे | Factorial (recursion), Fibonacci |
for i in range(1, 6):
print(i, end=" ")⏱️ Algorithm Complexity (Efficiency मापना)
- Time Complexity: Algorithm कितना समय लेगा — Big-O notation में: O(1) constant, O(n) linear, O(n²) quadratic।
- Space Complexity: कितनी memory लेगा।
Flowcharts — Algorithm की तस्वीर
🔣 Flowchart Symbols (Exam का पक्का प्रश्न)
| Symbol | नाम | उपयोग |
|---|---|---|
| ⬭ (Oval) | Terminal | Start / Stop |
| ▭ (Rectangle) | Process | Calculation या assignment (Sum = A+B) |
| ◇ (Diamond) | Decision | Condition check (Yes/No) |
| ▱ (Parallelogram) | Input/Output | Data लेना या result दिखाना |
| → (Arrow) | Flow Lines | Steps की दिशा |
| ◯ (Circle) | Connector | Flowchart के हिस्सों को जोड़ना |
📊 Example Flowchart — दो Numbers में बड़ा
Flowchart: Largest of Two Numbers
✔️ Flowchart बनाने के Rules
- हमेशा Start से शुरू और Stop पर खत्म।
- Flow की दिशा ऊपर से नीचे या बाएँ से दाएँ।
- Decision (diamond) से हमेशा 2 रास्ते निकलते हैं — Yes व No।
- Arrows एक-दूसरे को cross न करें; हर symbol में short, clear text।
⚖️ Algorithm vs Flowchart
| आधार | Algorithm | Flowchart |
|---|---|---|
| रूप | Text/steps में | Symbols/diagram में |
| समझना | पढ़ना पड़ता है | देखते ही समझ आता है |
| बनाना | आसान व तेज़ | Symbols से समय लगता है |
| Modification | आसान | पूरा redraw करना पड़ सकता है |
Compilation Process — Code से Execution तक का सफ़र
🏭 Compilation की 7 Stages (C जैसी compiled languages)
| Stage | क्या होता है |
|---|---|
| 1. Lexical Analysis | Code को tokens में तोड़ना (keywords, identifiers, operators) |
| 2. Syntax Analysis (Parsing) | Grammar rules के अनुसार structure check — parse tree बनता है |
| 3. Semantic Analysis | Meaning check — जैसे string को int से जोड़ नहीं सकते |
| 4. Intermediate Code Generation | Machine-independent बीच का code बनना |
| 5. Code Optimization | Code को fast व memory-efficient बनाना |
| 6. Code Generation | Final machine code बनना |
| 7. Linking & Loading | Libraries जोड़कर executable बनाना व memory में load करना |
🐍 Python का Execution Model — Bytecode + PVM
Python Program कैसे Run होता है
- Step 1: आप
.pyfile लिखते हैं (source code)। - Step 2: Python इसे internally bytecode (.pyc) में compile करता है — platform-independent बीच की भाषा।
- Step 3: PVM (Python Virtual Machine) bytecode को line-by-line execute करती है।
- Step 4: Output screen पर आता है।
Testing — Program सही चल रहा है या नहीं?
🧪 Testing के 4 मुख्य Types
| Type | क्या test होता है | Example |
|---|---|---|
| 1. Unit Testing | एक-एक function/module अलग से | सिर्फ add() function check करना |
| 2. Integration Testing | Modules आपस में मिलकर सही चलते हैं या नहीं | add() + display() साथ में |
| 3. System Testing | पूरा system एक साथ | पूरी calculator app |
| 4. Acceptance Testing | User की requirements पूरी हुईं या नहीं | Client द्वारा final approval |
def add(a, b):
return a + b
# Testing different cases
assert add(2, 3) == 5 # Pass
assert add(-1, 1) == 0 # Pass
assert add(0, 0) == 0 # Pass
print("All tests passed!")assert statement condition false होने पर error देता है — तीनों test cases pass हुए इसलिए आखिरी print चला। अगर add() में गलती होती (जैसे a - b), तो पहला ही assert fail करके AssertionError देता।Debugging & Error Handling — गलतियाँ ढूँढना व सुधारना
❌ Errors के 3 Types (सबसे Important Topic)
1️⃣ Syntax Error — Grammar की गलती
Language के rules टूटने पर — program चलता ही नहीं।
print("Hello" # closing bracket bhool gaye!2️⃣ Logical Error — सोच की गलती
Program चलता है, error नहीं आती — लेकिन output गलत आता है। सबसे खतरनाक, क्योंकि पकड़ना मुश्किल!
a = 10
b = 20
average = a + b / 2 # GALAT! pehle b/2 hoga (BODMAS)
print("Average =", average)3️⃣ Runtime Error — चलते-चलते Crash
Execution के दौरान आने वाली error — जैसे zero से divide, गलत index।
a = 10 b = 0 print(a / b) # zero se divide!
🛠️ Debugging की 4 Techniques
- 1. Print Statement Debugging: बीच-बीच में print() लगाकर values check करना (सबसे simple)।
- 2. Python Debugger (pdb):
import pdb; pdb.set_trace()से program को रोककर step-by-step देखना। - 3. IDE Debugger: VS Code/PyCharm में breakpoints लगाकर।
- 4. Exception Handling: try-except से errors को gracefully संभालना।
try:
a = int(input("Enter number: "))
result = 100 / a
print("Result =", result)
except ZeroDivisionError:
print("Error: Zero se divide nahi kar sakte!")
except ValueError:
print("Error: Sahi number enter karein!")Documentation — Code का Description लिखना
📝 Python में Documentation के 3 तरीके
1️⃣ Single-line Comments (#)
# Yah program area calculate karta hai
radius = 5 # circle ki radius
area = 3.14 * radius ** 2 # formula: πr²
print("Area =", area)2️⃣ Multi-line Comments (''' ''')
'''
Program: Simple Interest Calculator
Author: Boosting Skills
Date: 2026
Purpose: SI = (P × R × T) / 100 calculate karna
'''
p, r, t = 1000, 5, 2
si = (p * r * t) / 100
print("Simple Interest =", si)3️⃣ Docstrings — Functions की Official Documentation
def square(n):
"""Yah function number ka square return karta hai."""
return n * n
print(square(6))
print(square.__doc__) # docstring ko access karnaYah function number ka square return karta hai.
📋 Good Documentation के Rules
- Comments "क्यों" बताएँ, "क्या" नहीं (code खुद बताता है क्या हो रहा है)।
- Meaningful variable names रखें —
student_age, न किx। - हर function में docstring; ज़रूरत से ज़्यादा comments भी बुरे हैं।
- Documentation को code के साथ update रखें।
__doc__ से access)। Comments interpreter द्वारा ignore किए जाते हैं — execution पर असर नहीं।🎯 Output-Based Questions — Exam का सबसे Scoring हिस्सा
Q1. Print का basic behavior
print("5 + 3")
print(5 + 3)8
← Quotes में लिखा text वैसा ही print होता है; बिना quotes calculation होती है।
Q2. Integer vs Float Division
print(10 / 3) print(10 // 3) print(10 % 3)
3
1
← / हमेशा float देता है; // quotient (integer); % remainder।
Q3. Variable Update
x = 5 x = x + 2 x = x * 3 print(x)
← Step-by-step: x=5 → x=7 → x=21। (RAM model जैसा sequential execution!)
Q4. String Concatenation vs Addition
a = "10" b = "20" print(a + b) print(int(a) + int(b))
30
← Strings का + = जोड़ना नहीं, चिपकाना (concatenation)! int() से convert करने पर असली जोड़।
Q5. BODMAS Trap
result = 2 + 3 * 4 ** 2 print(result)
← Order: पहले ** (4²=16), फिर * (3×16=48), फिर + (2+48=50)।
Q6. Loop Output
for i in range(1, 6):
if i == 3:
continue
print(i, end=" ")← continue से i=3 वाला print skip हो गया; range(1,6) में 6 शामिल नहीं।
Q7. Condition का Output
a = 15
if a > 10:
print("Big")
if a > 20:
print("Bigger")
else:
print("Small")Small
← पहली if true (Big छपा); दूसरी if false इसलिए उसका else चला (Small)। दोनों अलग-अलग if हैं!
Q8. Error पहचानिए
x = int("hello")
print(x)← "hello" को number में बदला नहीं जा सकता — यह Runtime Error है (Syntax नहीं!)।
Q9. While Loop Trace
n = 10
while n > 0:
print(n, end=" ")
n = n - 3← n: 10→7→4→1→(-2 पर condition false, रुक गया)।
Q10. Logical Error पकड़िए
# 3 numbers ka average
a, b, c = 10, 20, 30
avg = a + b + c / 3
print("Average =", avg)← BODMAS से पहले c/3=10 हुआ, फिर 10+20+10=40। सही code: (a+b+c)/3 — यह Logical Error है (program चला, output गलत)।
Q11. Type पहचानिए
print(type(10))
print(type(10.5))
print(type("10"))<class 'float'>
<class 'str'>
← type() variable की class बताता है — exam में common question!
Q12. Assert का Behavior
def double(n):
return n * 2
assert double(4) == 8
print("Test 1 passed")
assert double(5) == 11
print("Test 2 passed")AssertionError
← पहला assert true (8==8) — print चला; दूसरा false (10≠11) — AssertionError पर program रुका।
💻 Practice Programs — Algorithm से Code तक
Program 1 — Factorial निकालना (Loop से)
n = int(input("Enter number: "))
fact = 1
for i in range(1, n + 1):
fact = fact * i
print("Factorial of", n, "=", fact)Program 2 — N Numbers का Sum व Average
n = int(input("Kitne numbers? "))
total = 0
for i in range(n):
num = float(input("Number " + str(i+1) + ": "))
total = total + num
average = total / n
print("Sum =", total)
print("Average =", average)Average = 20.0
Program 3 — 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 a Prime number")
else:
print(n, "is NOT a Prime number")Program 4 — Multiplication Table
n = int(input("Kis number ki table? "))
for i in range(1, 11):
print(n, "x", i, "=", n * i)7 x 2 = 14
... (10 lines तक)
7 x 10 = 70
Program 5 — Number Reverse करना
n = int(input("Enter number: "))
rev = 0
while n > 0:
digit = n % 10 # aakhri digit nikala
rev = rev * 10 + digit
n = n // 10 # aakhri digit hataya
print("Reversed =", rev)Program 6 — Fibonacci Series
n = int(input("Kitne terms? "))
a, b = 0, 1
for i in range(n):
print(a, end=" ")
a, b = b, a + bProgram 7 — Largest of Three Numbers
a = int(input("A: "))
b = int(input("B: "))
c = int(input("C: "))
if a >= b and a >= c:
print("Largest =", a)
elif b >= a and b >= c:
print("Largest =", b)
else:
print("Largest =", c)Program 8 — Palindrome Number Check
n = int(input("Enter number: "))
temp = n
rev = 0
while temp > 0:
rev = rev * 10 + temp % 10
temp = temp // 10
if n == rev:
print(n, "is a Palindrome")
else:
print(n, "is NOT a Palindrome")Summary — Quick Revision (Exam से पहले पढ़ें)
- Programming Language = computer से बात करने का माध्यम; 5 generations: Machine → Assembly → High-Level → 4GL → 5GL।
- Compiler = पूरा program एक साथ translate (C, C++); Interpreter = line-by-line (Python, JavaScript)।
- Models of Computation: Turing Machine (theory), Finite Automata (patterns), RAM Model (practice — O(1) memory access)।
- Algorithm = finite, well-defined steps; 5 characteristics = Finiteness, Definiteness, Input, Output, Effectiveness।
- Flowchart = algorithm का चित्र; Oval=Start/Stop, Rectangle=Process, Diamond=Decision, Parallelogram=I/O।
- Compilation की 7 stages: Lexical → Syntax → Semantic → Intermediate → Optimization → Code Gen → Linking।
- Python execution: .py → bytecode (.pyc) → PVM → Output; इसीलिए "Interpreted + Compiled"।
- Testing: Unit → Integration → System → Acceptance (छोटे से बड़े)।
- Errors: Syntax (चलने से पहले), Logical (गलत output), Runtime (crash — ZeroDivisionError आदि)।
- Documentation: # comments, ''' multi-line, docstrings (
__doc__) — good programming की पहचान।
Model Questions — 50 MCQs + 15 Theory Questions
❓ A. Multiple Choice Questions (50)
| # | प्रश्न व उत्तर |
|---|---|
| 1 | Computer सीधे कौन-सी language समझता है? (a) Assembly(b) Python(c) Machine Language(d) SQL ✔ सही उत्तर: (c) Machine Language0/1 में, बिना translation। |
| 2 | Machine language किस generation की है? (a) 1st(b) 2nd(c) 3rd(d) 4th ✔ सही उत्तर: (a) 1st |
| 3 | Assembly language में उपयोग होते हैं — (a) Binary digits(b) Mnemonics(c) Objects(d) Queries ✔ सही उत्तर: (b) MnemonicsMOV, ADD, SUB जैसे। |
| 4 | Assembly को machine code में बदलता है — (a) Compiler(b) Interpreter(c) Assembler(d) Linker ✔ सही उत्तर: (c) Assembler |
| 5 | Python किस generation की language है? (a) 1GL(b) 2GL(c) 3GL(d) 5GL ✔ सही उत्तर: (c) 3GLHigh-level language। |
| 6 | SQL किसका उदाहरण है? (a) 2GL(b) 3GL(c) 4GL(d) 5GL ✔ सही उत्तर: (c) 4GL |
| 7 | AI-oriented languages (जैसे Prolog) किस generation में आती हैं? (a) 3GL(b) 4GL(c) 5GL(d) 1GL ✔ सही उत्तर: (c) 5GL |
| 8 | Programmer द्वारा लिखा गया high-level code कहलाता है — (a) Object code(b) Source code(c) Byte code(d) Executable ✔ सही उत्तर: (b) Source code |
| 9 | Language के grammatical rules कहलाते हैं — (a) Semantics(b) Syntax(c) Logic(d) Tokens ✔ सही उत्तर: (b) Syntax |
| 10 | Code का meaning/behavior कहलाता है — (a) Syntax(b) Semantics(c) Grammar(d) Structure ✔ सही उत्तर: (b) Semantics |
| 11 | Compiler translate करता है — (a) Line-by-line(b) पूरा program एक साथ(c) आधा-आधा(d) कुछ नहीं ✔ सही उत्तर: (b) पूरा program एक साथ |
| 12 | Interpreter की विशेषता है — (a) Object code बनाता है(b) पहली error पर रुकता है(c) Fast execution(d) सभी errors एक साथ ✔ सही उत्तर: (b) पहली error पर रुकता है |
| 13 | इनमें से compiled language है — (a) Python(b) JavaScript(c) C(d) HTML ✔ सही उत्तर: (c) C |
| 14 | Python है — (a) Compiled only(b) Interpreted only(c) Interpreted + Compiled(d) Assembly ✔ सही उत्तर: (c) Interpreted + Compiledbytecode बनता है, PVM execute करती है। |
| 15 | Execution speed में तेज़ होता है — (a) Interpreter(b) Compiler(c) दोनों बराबर(d) कोई नहीं ✔ सही उत्तर: (b) Compilerpre-compiled होने से। |
| 16 | Turing Machine किसने दी? (a) Charles Babbage(b) Alan Turing(c) Dennis Ritchie(d) Guido van Rossum ✔ सही उत्तर: (b) Alan Turing |
| 17 | Turing Machine का part नहीं है — (a) Infinite Tape(b) Head(c) Control Unit(d) Monitor ✔ सही उत्तर: (d) Monitor |
| 18 | DFA में एक symbol के लिए next states होती हैं — (a) कई(b) केवल एक(c) शून्य(d) अनंत ✔ सही उत्तर: (b) केवल एकDeterministic। |
| 19 | RAM Model में memory access की complexity है — (a) O(n)(b) O(n²)(c) O(1)(d) O(log n) ✔ सही उत्तर: (c) O(1)किसी भी location पर सीधी पहुँच। |
| 20 | Computational model के components हैं — (a) Input, Process, Output(b) Storage(c) Control Unit(d) उपरोक्त सभी ✔ सही उत्तर: (d) उपरोक्त सभी |
| 21 | Algorithm है — (a) Diagram(b) Steps का finite sequence(c) Hardware(d) Language ✔ सही उत्तर: (b) Steps का finite sequence |
| 22 | Algorithm की कौन-सी characteristic कहती है कि वह finite steps में खत्म हो? (a) Definiteness(b) Finiteness(c) Effectiveness(d) Input ✔ सही उत्तर: (b) Finiteness |
| 23 | "हर step clear व unambiguous हो" — यह है — (a) Finiteness(b) Definiteness(c) Output(d) Input ✔ सही उत्तर: (b) Definiteness |
| 24 | Algorithm में कम से कम कितने output होने चाहिए? (a) 0(b) 1(c) 2(d) अनगिनत ✔ सही उत्तर: (b) 1 |
| 25 | Algorithm में inputs हो सकते हैं — (a) केवल 1(b) कम से कम 2(c) 0 या अधिक(d) अनिवार्य 5 ✔ सही उत्तर: (c) 0 या अधिक |
| 26 | if-else पर आधारित algorithm कहलाता है — (a) Sequential(b) Conditional(c) Iterative(d) Recursive ✔ सही उत्तर: (b) Conditional |
| 27 | Loop पर आधारित algorithm है — (a) Sequential(b) Conditional(c) Iterative(d) Static ✔ सही उत्तर: (c) Iterative |
| 28 | Algorithm का समय मापा जाता है — (a) Space Complexity(b) Time Complexity(c) Length(d) Weight ✔ सही उत्तर: (b) Time Complexity |
| 29 | O(n) का अर्थ है — (a) Constant time(b) समय input के साथ linear बढ़ता है(c) समय घटता है(d) कोई संबंध नहीं ✔ सही उत्तर: (b) linear बढ़ता है |
| 30 | Algorithm लिखा जाता है — (a) केवल Python में(b) केवल C में(c) किसी भी भाषा (language-independent) में(d) Binary में ✔ सही उत्तर: (c) language-independent |
| 31 | Flowchart है — (a) Program की तस्वीर(b) Algorithm का graphical रूप(c) Testing tool(d) Compiler ✔ सही उत्तर: (b) Algorithm का graphical रूप |
| 32 | Start/Stop के लिए symbol — (a) Rectangle(b) Diamond(c) Oval(d) Circle ✔ सही उत्तर: (c) Oval |
| 33 | Decision (condition) के लिए symbol — (a) Oval(b) Diamond(c) Rectangle(d) Arrow ✔ सही उत्तर: (b) Diamond |
| 34 | Input/Output के लिए symbol — (a) Parallelogram(b) Oval(c) Diamond(d) Rectangle ✔ सही उत्तर: (a) Parallelogram |
| 35 | Process (calculation) के लिए symbol — (a) Circle(b) Rectangle(c) Oval(d) Diamond ✔ सही उत्तर: (b) Rectangle |
| 36 | Flowchart के दो भागों को जोड़ता है — (a) Arrow(b) Connector (Circle)(c) Diamond(d) Oval ✔ सही उत्तर: (b) Connector (Circle) |
| 37 | Decision symbol से कितने रास्ते निकलते हैं? (a) 1(b) 2 (Yes/No)(c) 4(d) कोई नहीं ✔ सही उत्तर: (b) 2 (Yes/No) |
| 38 | Compilation की पहली stage है — (a) Syntax Analysis(b) Lexical Analysis(c) Code Generation(d) Linking ✔ सही उत्तर: (b) Lexical Analysis |
| 39 | Lexical Analysis में code टूटता है — (a) Objects में(b) Tokens में(c) Files में(d) Loops में ✔ सही उत्तर: (b) Tokens में |
| 40 | Parse tree बनता है — (a) Lexical(b) Syntax Analysis(c) Optimization(d) Loading ✔ सही उत्तर: (b) Syntax Analysis |
| 41 | Type mismatch (जैसे "abc" + 5) पकड़ी जाती है — (a) Lexical(b) Semantic Analysis(c) Linking(d) Loading ✔ सही उत्तर: (b) Semantic Analysis |
| 42 | Python का source code internally बदलता है — (a) .exe में(b) Bytecode (.pyc) में(c) HTML में(d) Assembly में ✔ सही उत्तर: (b) Bytecode (.pyc) |
| 43 | Python bytecode को execute करती है — (a) CPU सीधे(b) PVM(c) Assembler(d) Browser ✔ सही उत्तर: (b) PVMPython Virtual Machine। |
| 44 | Libraries जोड़कर executable बनाने का काम है — (a) Lexical(b) Linking(c) Parsing(d) Testing ✔ सही उत्तर: (b) Linking |
| 45 | सबसे पहले की जाने वाली testing — (a) System(b) Acceptance(c) Unit(d) Integration ✔ सही उत्तर: (c) Unit Testing |
| 46 | User की requirements की final जाँच — (a) Unit(b) Integration(c) Acceptance Testing(d) Lexical ✔ सही उत्तर: (c) Acceptance Testing |
| 47 | print("Hello" (bracket बंद नहीं) — कौन-सी error? (a) Logical(b) Runtime(c) Syntax(d) कोई नहीं ✔ सही उत्तर: (c) Syntax Error |
| 48 | Program चलता है पर output गलत आता है — error है — (a) Syntax(b) Logical(c) Runtime(d) Linker ✔ सही उत्तर: (b) Logical Error |
| 49 | 10/0 करने पर आती है — (a) SyntaxError(b) ValueError(c) ZeroDivisionError(d) TypeError ✔ सही उत्तर: (c) ZeroDivisionErrorRuntime error। |
| 50 | Python में function की documentation लिखी जाती है — (a) # से(b) Docstring (""" """) से(c) // से(d) <!-- --> से ✔ सही उत्तर: (b) Docstring __doc__ से access होती है। |
📝 B. 15 Theory Questions (Short Answers)
- Programming language क्या है और इसकी ज़रूरत क्यों है?Computer को instructions देने का माध्यम। Computer केवल binary समझता है, मनुष्य के लिए binary कठिन है — इसलिए human-readable languages चाहिए जिन्हें compiler/interpreter translate करे।
- Languages की 5 generations बताइए।1GL Machine (0/1), 2GL Assembly (mnemonics), 3GL High-Level (Python, C), 4GL (SQL, MATLAB), 5GL AI-based (Prolog)।
- Compiler और Interpreter में 4 अंतर लिखिए।Compiler: पूरा program एक साथ, fast, सभी errors एक साथ, object code बनता है (C)। Interpreter: line-by-line, slow, पहली error पर रुकता, object code नहीं (Python)।
- Source code व Object code में अंतर बताइए।Source code = programmer द्वारा लिखा high-level code (.py); Object code = translate किया हुआ machine-readable code।
- Turing Machine के 3 parts बताइए।Infinite Tape (symbols के लिए), Head (पढ़ने-लिखने के लिए), Control Unit (next step तय करने के लिए)।
- DFA और NFA में क्या अंतर है?DFA में हर symbol के लिए केवल एक next state; NFA में एक symbol के लिए कई possible states हो सकती हैं।
- RAM Model की विशेषताएँ लिखिए।हर instruction = 1 unit time; memory access O(1); algorithm analysis के लिए सबसे उपयुक्त practical model।
- Algorithm की 5 characteristics बताइए।Finiteness (finite steps), Definiteness (हर step clear), Input (0+), Output (1+), Effectiveness (steps simple व practical)।
- Flowchart के 5 symbols व उनके उपयोग लिखिए।Oval = Start/Stop; Rectangle = Process; Diamond = Decision; Parallelogram = Input/Output; Arrow = flow direction।
- Algorithm और Flowchart में अंतर बताइए।Algorithm text/steps में होता है, बनाना आसान, modify करना आसान; Flowchart symbols/diagram में, देखते ही समझ आता है पर redraw करना पड़ता है।
- Compilation की 7 stages क्रम से लिखिए।Lexical Analysis → Syntax Analysis → Semantic Analysis → Intermediate Code → Code Optimization → Code Generation → Linking & Loading।
- Python को Interpreted + Compiled क्यों कहते हैं?क्योंकि .py source पहले internally bytecode (.pyc) में compile होता है, फिर PVM उस bytecode को line-by-line interpret/execute करती है।
- Testing के 4 types क्रम से बताइए।Unit (एक function), Integration (modules साथ में), System (पूरा system), Acceptance (user requirements) — छोटे से बड़े की ओर।
- Errors के 3 types उदाहरण सहित लिखिए।Syntax (bracket missing — चलने से पहले), Logical (गलत formula — output गलत), Runtime (10/0 — ZeroDivisionError, चलते हुए crash)।
- Python में documentation के तरीके बताइए।# single-line comments, ''' ''' multi-line comments, और docstrings (function की पहली line पर """ """, __doc__ से access) — interpreter इन्हें ignore करता है।