Free tutorials & notes in Hindi & English · Clean code examples 🧰 मुफ़्त PDF और फ़ोटो टूल्स →
🐍 Unit 1 – Python Revision और Functions  ·  Lesson 01

Python Revision Tour

Tokens, variables और data types

Class XII, Class XI की हर चीज़ पर टिका है। Python program tokens से बनता है: keywords (if, def, return), identifiers (total), literals (25, 'CS', True, None), operators (+ == and) और punctuators (( ) [ ] : ,)। Variables objects से जुड़े नाम हैं; type value से आता है (dynamic typing)।

Data 📁 types/
├── 📁 Numbers/      int, float, complex, bool
├── 📁 Sequences/    str, list, tuple
├── 📁 Mapping/      dict
├── 📁 Set/          set
└── None
Built-in data types

Mutable vs immutable

Immutable

  • int, float, bool, str, tuple
  • बदलने पर नया object बनता है
  • Dictionary keys बन सकते हैं

Mutable

  • list, dict, set
  • उसी जगह बदलते हैं — share करने वाले हर नाम को बदलाव दिखता है
  • Dictionary keys नहीं बन सकते
Output questions का सबसे ज़्यादा पूछा जाने वाला concept
Python
a = [1, 2, 3]
b = a
c = a[:]
b.append(4)
c.append(5)
print(a, b, c)
s = 'cs'
s2 = s
s2 += '12'
print(s, s2)
[1, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 5] cs cs12

b = a alias बनाता है; c = a[:] copy बनाता है। Strings immutable हैं, इसलिए s2 += '12' नई string बनाता है और s नहीं बदलती।

Operators और precedence

ऊँचे से नीचे क्रम: () → ** (दाएँ से बाएँ) → unary + - ~ → * / // % → + - → comparisons, in, is → not → and → or।

Python
print(5 // 2 * 2, 2 ** 3 ** 0, not 0 or 5, 7 and 0, 'a' < 'B')
4 2 True 0 False

7 and 0 0 return करता है (पहली false value); 'a' < 'B' False है क्योंकि 'a' 97 है और 'B' 66।

Flow of control

⬇️
SequenceStatements एक के बाद एक।
🔀
Selectionif, if-else, if-elif-else, nested if।
🔁
Iterationfor (range या sequence के साथ), while; break, continue, loop-else।
तीन control structures
Python
x = 10
while x > 0:
    x -= 3
print(x)
for i in range(3):
    pass
else:
    print('loop finished, i =', i)
-2 loop finished, i = 2

Strings

B0o1a2r3d4␣5E6x7a8m9
s[6:10] → "Exam"
Python
s = 'Board Exam 2026'
print(s[6:10], s[-4:], s.lower().count('a'))
print(s.split(), s.replace(' ', '-'))
Exam 2026 2 ['Board', 'Exam', '2026'] Board-Exam-2026

ज़रूरी methods: len, upper, lower, title, capitalize, count, find, index, replace, split, join, strip, startswith, endswith, isalpha, isdigit, isalnum, isupper, islower, isspace।

Lists, tuples और dictionaries

Python
L = [5, 'two', 3.0, [7, 8]]
print(len(L), L[3][1], L[-2:])
t = (1, 2, 3) * 2
print(t, t.index(3))
d = {'a': 1}
d.setdefault('b', 2)
print(d, list(d.items()))
4 8 [3.0, [7, 8]] (1, 2, 3, 1, 2, 3) 2 {'a': 1, 'b': 2} [('a', 1), ('b', 2)]
Typeमुख्य methods
listappend, extend, insert, pop, remove, index, count, sort, reverse, copy, clear
tuplecount, index (और len, max, min, sum, sorted)
dictkeys, values, items, get, update, pop, popitem, setdefault, copy, clear, fromkeys

Comprehensions

Python
print([i * i for i in range(6) if i % 2])
print({k: len(k) for k in ['cs', 'ip', 'maths']})
[1, 9, 25] {'cs': 2, 'ip': 2, 'maths': 5}

Board-style output questions

Output बताइए (शब्द-दर-शब्द trace करें):

Python
text = 'Python Is Easy To Learn'
words = text.split()
new = ''
for w in words:
    if len(w) > 2:
        new += w[0].lower() + w[1:].upper() + ' '
    else:
        new += w + ' '
print(new.strip())
pYTHON Is eASY To lEARN
✅ ख़ुद करें

Output बताइए: L = [2, 4, 6]; L[1:2] = [9, 9]; print(L, len(L)) और print('-'.join('CS'.lower() * 2))।

Answers: [2, 9, 9, 6] 4 और c-s-c-s।

Quick revision table

Conceptयाद रखें
Integer division-7 // 2 = -4 (floor), -7 % 2 = 1
Slicings[a:b] में b शामिल नहीं; s[::-1] उल्टा
Single-item tuple(5,) न कि (5)
Dictionary keysUnique, immutable
Alias vs copyb = a share करता है; a[:], list(a), a.copy() copy करते हैं
Loop elsebreak न हो तभी चलता है

अक्सर पूछे जाने वाले प्रश्न (FAQ)

Class 12 CS के लिए Class 11 के कौन से topics चाहिए?
Data types, operators, flow of control, strings, lists, tuples और dictionaries। Board papers में इन पर output और error-finding questions अक्सर आते हैं।
2 ** 3 ** 0 की value क्या है?
2, क्योंकि ** दाएँ से बाएँ evaluate होता है: 3 ** 0 = 1, फिर 2 ** 1 = 2।
not 0 or 5 क्या return करता है?
True। not 0 True है, और or पहला true operand return करता है, जो True है।
← Class 12 Computer Science
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

अगला topicFunctions: Types और Arguments आपकी प्रगति: 1 / 26 (4%) · Lesson 2 / 26 आगे बढ़ें →

यह lesson कैसा लगा?

आपकी राय से हम content और बेहतर बनाते हैं।

अपना review और सुझाव लिखें (वैकल्पिक)

Review approve होने के बाद आपका नाम और शहर इसके साथ public दिख सकते हैं। Email या phone न लिखें।

▶ CodingEasily on YouTube

Video से सीखें – आसान Hindi में

चुनी हुई video: RDBMS भाग 3 – Class XI Commerce IT

▶ Channel subscribe करें