ज़रूरी Questions और Viva
Python और functions
Q1. Parameter और argument में अंतर बताइए।
Function header में लिखा variable parameter है (def area(r)); call में भेजी गई असली value argument है (area(5))।
Q2. Default और keyword arguments क्या हैं?
Default argument की value header में होती है (def f(a, b=5)) और value न भेजने पर वही लगती है। Keyword arguments नाम से भेजे जाते हैं (f(b=2, a=1)) इसलिए क्रम मायने नहीं रखता। Default parameters non-default के बाद आने चाहिए।
Q3. Local और global variables में अंतर बताइए।
Local variable function के अंदर बनता है और वहीं रहता है। Global variable सभी functions के बाहर बनता है और कहीं भी पढ़ा जा सकता है; function के अंदर बदलने के लिए global लिखें।
Q4. List value से pass होती है या reference से?
Python references भेजता है। Function के अंदर mutable object (list, dict) में किए बदलाव बाहर दिखते हैं; parameter को दोबारा assign करना नहीं।
Q5. finally block का क्या उपयोग है?
finally का code हमेशा चलता है, exception आए या न आए – files या connections बंद करने के लिए।
Output-based questions
def change(a, b=5):
a = a + b
b = a - b
return a, b
x, y = change(10)
print(x, y)
print(change(3, 4))total = 0
def add(n):
global total
total += n
return total
add(5); add(7)
print(total)s = 'BoardExam2025'
print(s[2:7], s[-4:], s[::3])
print(s.upper().count('A'), s.find('Exam'))L = [10, 20, 30]
try:
print(L[3])
except IndexError:
print('Index error')
else:
print('No error')
finally:
print('Done')d = {'a': 1, 'b': 2}
d['c'] = d.get('a') + d.get('z', 10)
print(d, len(d))File handling
Q6. Text और binary files में अंतर बताइए।
Text files किसी भी editor में पढ़े जा सकने वाले characters रखती हैं और हर line EOL पर ख़त्म होती है। Binary files data memory वाले रूप में (pickle) रखती हैं, इंसान नहीं पढ़ सकता; EOL translation नहीं।
Q7. 'w' और 'a' mode में क्या फ़र्क है?
'w' नई file बनाता है या पुरानी मिटा देता है। 'a' पुराना content रखते हुए अंत में data जोड़ता है।
Q8. read(), readline() और readlines() में अंतर।
read() पूरी file (या n characters) string में देता है, readline() एक line, readlines() सभी lines की list।
Q9. dump() और load() क्या हैं?
pickle module के functions: dump(obj, file) object को binary file में लिखता (serialise) है, load(file) वापस पढ़ता है। File के अंत पर load EOFError देता है।
Q10. CSV files के साथ newline="" क्यों?
यह Windows पर rows के बीच extra ख़ाली line रोकता है क्योंकि csv module अपनी line endings ख़ुद लिखता है।
with open('t.txt', 'w') as f:
f.write('ABCDEFGH')
with open('t.txt') as f:
print(f.read(3))
print(f.tell())
f.seek(5)
print(f.read())Stack
Q11. Stack क्या है? दो applications बताइए।
LIFO linear data structure जिसमें insertion और deletion top पर होते हैं। Applications: editors में undo, string उल्टी करना, brackets balance करना, postfix evaluate करना, function calls।
Q12. A + B * C - D / E को postfix में बदलिए।
A B C * + D E / -
Q13. Postfix expression 6 2 / 3 - 4 2 * + evaluate कीजिए।
6/2 = 3 → 3−3 = 0 → 4×2 = 8 → 0+8 = 8।
Computer networks
Q14. Hub और switch में अंतर बताइए।
Hub data सभी ports पर broadcast करता है; switch MAC addresses से उसे सिर्फ़ destination port पर भेजता है, इसलिए तेज़ और ज़्यादा सुरक्षित है।
Q15. Expand करें: HTTP, FTP, SMTP, POP, VoIP, TCP/IP, URL, DNS।
HyperText Transfer Protocol, File Transfer Protocol, Simple Mail Transfer Protocol, Post Office Protocol, Voice over Internet Protocol, Transmission Control Protocol/Internet Protocol, Uniform Resource Locator, Domain Name System।
Q16. 2 km दूर दो buildings जोड़ने के लिए कौन सा medium?
Optical fibre – लंबी दूरी पर तेज़ और interference से मुक्त। लंबी copper cable में repeaters चाहिए।
Q17. Virus और worm में अंतर।
Virus को फैलने के लिए host file और user action चाहिए; worm अपने आप में पूरा है और network पर ख़ुद फैलता है।
Q18. Web page और website में क्या फ़र्क है?
Web page एक HTML document है; website एक domain के अंतर्गत जुड़े web pages का संग्रह है।
Database और SQL
Q19. Degree और cardinality परिभाषित करें।
Degree = attributes (columns) की संख्या; cardinality = tuples (rows) की संख्या।
Q20. Primary key और candidate key में अंतर।
Rows को uniquely पहचान सकने वाले सभी attributes candidate keys हैं; उनमें से चुनी गई primary key है। बाकी alternate keys हैं।
Q21. DELETE और DROP में अंतर।
DELETE DML है और rows हटाता है (table रहती है); DROP DDL है और data समेत table का structure हटाता है।
Q22. WHERE और HAVING में अंतर।
WHERE grouping से पहले rows filter करता है; HAVING GROUP BY के बाद groups filter करता है और aggregate functions ले सकता है।
Q23. 10 rows में 2 NULL वाले column पर SELECT COUNT(*), COUNT(col) का output?
COUNT(*) = 10, COUNT(col) = 8।
Q24. Equi-join और natural join में अंतर।
Equi-join common column पर = लगाता है और उसकी दोनों copies रखता है; natural join एक जैसे नाम वाले columns पर join करके column एक बार दिखाता है।
Python–MySQL
Q25. Python को MySQL से जोड़ने के steps बताइए।
import mysql.connector → connect() → cursor() → execute() → fetchall()/commit() → close()।
Q26. commit() का क्या उपयोग है?
यह INSERT, UPDATE या DELETE से हुए बदलाव हमेशा के लिए save करता है।
Q27. cursor.rowcount क्या लौटाता है?
SELECT से अब तक fetch हुई rows की संख्या, या INSERT/UPDATE/DELETE से प्रभावित rows।
Viva questions
Module क्या है? इस्तेमाल किए दो modules बताइए।
Functions और variables वाली .py file जिसे import किया जा सके; जैसे math, random, pickle, csv, mysql.connector।
seek() function का उपयोग?
यह file pointer को दी गई byte position पर ले जाता है; tell() वर्तमान position बताता है।
Exception क्या है?
ZeroDivisionError या ValueError जैसी runtime error, जिसे try–except से संभालते हैं।
Foreign key क्या है?
एक table का attribute जो दूसरी table की primary key को refer करता है, data consistent रखता है।
IP address क्या है?
Network पर हर device का unique logical address, जैसे 192.168.1.10।
Exam tips
- 1Function header ठीक वैसा लिखें जैसा पूछा गया (नाम और parameters)
- 2File programs में file हमेशा close करें या with लिखें
- 3Output questions में trace table दिखाएँ
- 4SQL में हर query ; पर ख़त्म करें और text quotes में लिखें
- 5Network case study: हर उत्तर के साथ कारण लिखें
