Home › Hindi › Class 12 output questions

Class 12 Python output questions Hindi में — 8 board-style सवाल, पूरे answers के साथ

🌐 यह page Hindi में है · Read this in English →

8 सवाल + step-by-step answerCBSE board patternFree browser practice

Board exam में output वाले सवाल कैसे आते हैं

CBSE Class 12 Computer Science (083) और Informatics Practices (065) दोनों में "Find the output of the following code" लगभग हर साल आता है — आमतौर पर 1 से 3 marks का। ये सवाल आपका coding नहीं, आपका tracing test करते हैं: क्या आप code को Python की तरह line-by-line पढ़ सकते हो।

सबसे बड़ी बात: इन सवालों में marks पूरे मिलते हैं या बिल्कुल नहीं। एक space, एक comma, एक bracket गलत — पूरा answer गलत। इसलिए output लिखते समय exact format ही लिखो — list है तो [1, 2, 3] (comma के बाद space), string है तो quotes के बिना।

नीचे 8 सवाल हैं जो board pattern से बिल्कुल मिलते-जुलते हैं। हर सवाल खुद try करो, फिर answer खोलो।

Q1 — List slicing (हर साल आता है)

L = [10, 20, 30, 40, 50, 60]
print(L[1:4])
print(L[:3])
print(L[-2:])
print(L[::2])

Answer:

[20, 30, 40]
[10, 20, 30]
[50, 60]
[10, 30, 50]

Rule जो याद रखना है: slicing में start शामिल, stop शामिल नहीं। L[1:4] का मतलब index 1, 2, 3 — index 4 नहीं। L[::2] में तीसरा number step है, यानी हर दूसरा element।

Q2 — range() के bounds

for i in range(1, 10, 3):
    print(i, end=" ")

Answer: 1 4 7

range(start, stop, step) में stop कभी शामिल नहीं होता। 1 से शुरू, हर बार 3 जोड़ो: 1, 4, 7 — अगला 10 होता जो stop है, इसलिए रुक गया। end=" " की वजह से सब एक ही line में space के साथ छपे।

Trap: अगर end=" " न हो तो हर number नई line में आएगा — answer sheet पर इसे अलग-अलग lines में लिखना पड़ेगा।

Q3 — String immutability और methods

S = "CBSE Exam"
S.upper()
print(S)
print(S.upper())
print(S[0:4] * 2)

Answer:

CBSE Exam
CBSE EXAM
CBSECBSE

क्यों: strings immutable हैं। S.upper() एक नई string बनाकर लौटाता है — पुरानी S नहीं बदलती। अकेली line S.upper() का result कहीं store नहीं हुआ, इसलिए बेकार चली गई। यह board का favourite trap है।

Q4 — List mutable है (reference वाला खेल)

A = [1, 2, 3]
B = A
B.append(4)
print(A)
print(B)
print(A is B)

Answer:

[1, 2, 3, 4]
[1, 2, 3, 4]
True

B = A copy नहीं बनाता — दोनों नाम एक ही list को point करते हैं। असली copy चाहिए तो B = A.copy() या B = A[:] लिखो, तब A अलग रहेगा।

Q5 — Dictionary और get()

D = {"Hindi": 85, "Maths": 92}
print(D.get("Maths"))
print(D.get("English"))
print(D.get("English", 0))
print(len(D))

Answer:

92
None
0
2

D["English"] लिखते तो KeyError आता और program रुक जाता। get() crash नहीं करता — key न मिले तो None देता है, और default दिया हो तो वही देता है।

Q6 — Function और default argument

def total(a, b=10, c=20):
    return a + b + c

print(total(5))
print(total(5, 15))
print(total(5, c=1))

Answer:

35
40
16

Default values सिर्फ तब use होती हैं जब वह argument दिया ही न गया हो। तीसरे call में b default 10 रहा और c keyword से 1 बन गया: 5 + 10 + 1 = 16.

Q7 — Global बनाम local variable

x = 10
def change():
    x = 20
    print("Inside:", x)

change()
print("Outside:", x)

Answer:

Inside: 20
Outside: 10

Function के अंदर x = 20 ने एक नया local x बनाया, बाहर वाला छुआ तक नहीं। बाहर वाला बदलना हो तो function में global x लिखना पड़ता — पर board में यही difference पूछा जाता है।

Q8 — Tuple और unpacking

T = (1, 2, 3, 4)
a, b, *c = T
print(a, b)
print(c)
print(T * 2)
print(len(T * 2))

Answer:

1 2
[3, 4]
(1, 2, 3, 4, 1, 2, 3, 4)
8

ध्यान दो: *c हमेशा list बनाता है, tuple नहीं — इसीलिए square brackets में छपा। और T * 2 tuple को जोड़ता है, हर element को 2 से गुणा नहीं करता।

Exam में सबसे ज़्यादा marks कहाँ कटते हैं

आखिरी सलाह: paper में हर line के आगे pencil से variable की current value लिखते चलो। यह "dry run" तरीका 90% tracing galtiyan रोक देता है।

🛠️ Practice करो (free, browser में)

पढ़ना काफी नहीं — यही bug खुद fix करके देखो। नीचे के problems browser में ही चलते हैं, कोई install नहीं, कोई login नहीं।

सारे free problems देखो →

अक्सर पूछे जाने वाले सवाल

CBSE Class 12 में Python output questions कितने marks के आते हैं?

आमतौर पर 1 से 3 marks के, और लगभग हर साल आते हैं। Computer Science (083) और Informatics Practices (065) दोनों के पेपर में "Find the output" एक standard question type है।

output लिखते समय quotes लगाने चाहिए या नहीं?

नहीं। print() string को बिना quotes के दिखाता है, इसलिए print("hi") का output सिर्फ hi है। हाँ, अगर list या dictionary के अंदर string है तो वहाँ quotes दिखते हैं।

10 / 2 और 10 // 2 के output में क्या फर्क है?

10 / 2 का output 5.0 है क्योंकि एक slash वाला division हमेशा float देता है। 10 // 2 का output 5 है क्योंकि floor division पूरा हिस्सा ही देता है।

Class 12 Python output questions free में कहाँ practice करें?

PyDebug पर 55+ output-prediction questions browser में ही चलते हैं — आप answer लिखते हो, फिर असली Python से code चलाकर मिलान होता है। कोई install या payment नहीं।

आगे पढ़ो