Class 11 Computer Science (083) has three units. Unit 2, Computational Thinking and Programming – 1, is the Python one, and it is the unit this page is built for: every topic below names what the syllabus asks, links the PyRun lesson that teaches it, and gives one program written the way a board answer is written, already run on Python 3.12.
9 topics · 9 programs, each run on Python 3.12. Marks and unit weightage change by year and are not listed here — read the current Computer Science (083) curriculum on cbseacademic.nic.in.
The Class 11 practical is built around Python programs (the exact scheme — lab test, practical file, project, viva — is in the current curriculum document). Every program on this page runs in the online compiler at /practice with nothing installed, so the practical file can be tried on a phone or a school computer that has no Python.
Unit 1 · Theory — not covered on PyRun
Computer Systems and Organisation
Basic computer organisation, types of software, Boolean logic, number systems (binary, octal, hexadecimal) and encoding schemes (ASCII, ISCII, Unicode).
Not covered on PyRun: This is a theory unit. PyRun has no lessons on computer organisation, Boolean algebra or encoding schemes — use your textbook. The one place Python helps is number-system conversion, below.
1.Number systems in Python (the checkable part)
CBSE expects: Convert between decimal, binary, octal and hexadecimal by hand; know that ASCII/Unicode map characters to numbers.
No PyRun lesson covers number systems. Python's built-ins let you check a hand conversion in one line.
Board-style program: Check a conversion done on paper
Problem solving (algorithms, flowcharts, pseudocode), then Python from tokens to dictionaries. This is the unit PyRun's beginner lessons cover end to end.
1.Python basics: tokens, input/output, data types, type conversion
CBSE expects: Know keywords, identifiers, literals and operators; read input with input(), print with print(); name the core data types and convert between them (implicit vs explicit).
Board-style program: Read three values, convert them, print their types
# Tokens: keywords (if), identifiers (name, age), literals (18, "Name:"), operators (<, +)
name = input("Enter your name: ") # input() always returns a str
age = int(input("Enter your age: ")) # explicit conversion: str -> int
height = float(input("Enter height in m: "))
is_minor = age < 18 # bool
print("Name:", name, "| Age:", age, "| Height:", height)
print(type(name), type(age), type(height), type(is_minor))
print(age + height) # implicit conversion: int + float -> float
print(str(age) + " years") # str + str joins text; str + int is a TypeError
print(int(9.99), float(3), bool(0), bool("0"))
print(type((1, 2)), type([1, 2]), type({"a": 1}), type(None))
Typed in: Asha ⏎ 16 ⏎ 1.62
Output (Python 3.12)
Enter your name: Enter your age: Enter height in m: Name: Asha | Age: 16 | Height: 1.62
<class 'str'> <class 'int'> <class 'float'> <class 'bool'>
17.62
16 years
9 3.0 False True
<class 'tuple'> <class 'list'> <class 'dict'> <class 'NoneType'>
The online compiler cannot read typed input yet: input() raises an error there. To run a program that asks for input, replace each input(...) with the value shown under "Typed in" — e.g. n = int("29") — then press Run. The output on this page was produced with those same values on Python 3.12.
2.Operators and expressions
CBSE expects: Arithmetic, relational, logical, assignment, identity and membership operators; operator precedence; evaluate an expression by hand.
Board-style program: Every operator family, with the results CBSE asks you to predict
x, y = 17, 5
print(x + y, x - y, x * y)
print(x / y, x // y, x % y, x ** 2) # 3.4 3 2 289
print(-17 // 5, -17 % 5) # floor division rounds DOWN: -4 3
print(2 + 3 * 4 ** 2 / 8) # precedence: ** then * / then +
print(x > y and y != 0, not (x == y), x > 20 or y > 3)
print("a" in "Delhi", 3 in [1, 2, 3], "z" not in "pyrun") # membership
p = q = [1, 2]
print(p is q, p == [1, 2], p is [1, 2]) # identity vs equality
x += 3
x //= 4
print(x)
3.Flow of control: if / elif / else, for, while, break, continue
CBSE expects: Write selection with if-elif-else, iterate with for over range() and sequences, use while with a sentinel, and use break/continue; classic programs: prime check, patterns, sum of digits.
Board-style program: Prime check with for-else, a star pattern, a while loop with a sentinel
n = int(input("Enter a number: "))
if n < 2:
print(n, "is not prime")
else:
for i in range(2, n):
if n % i == 0:
print(n, "is not prime")
break
else: # runs only if the loop did NOT break
print(n, "is prime")
rows = 4
for i in range(1, rows + 1): # pattern with nested repetition
print("* " * i)
total = 0
while True: # sentinel-controlled loop
m = int(input("Enter marks (-1 to stop): "))
if m == -1:
break
if m > 100:
continue # skip invalid marks
total += m
print("Total marks:", total)
Typed in: 29 ⏎ 78 ⏎ 120 ⏎ 92 ⏎ -1
Output (Python 3.12)
Enter a number: 29 is prime
*
* *
* * *
* * * *
Enter marks (-1 to stop): Enter marks (-1 to stop): Enter marks (-1 to stop): Enter marks (-1 to stop): Total marks: 170
The online compiler cannot read typed input yet: input() raises an error there. To run a program that asks for input, replace each input(...) with the value shown under "Typed in" — e.g. n = int("29") — then press Run. The output on this page was produced with those same values on Python 3.12.
4.Strings: indexing, slicing, traversal and built-in methods
CBSE expects: Index and slice strings (including negative indexes), traverse with for, and use len, lower/upper, title, count, find, index, startswith/endswith, isalpha/isdigit/isalnum, strip, replace, split, join, partition.
Board-style program: Count vowels, test a palindrome, exercise the common methods
s = input("Enter a string: ")
vowels = 0
for ch in s: # traversal
if ch.lower() in "aeiou":
vowels += 1
print("Vowels:", vowels)
clean = s.replace(" ", "").lower()
if clean == clean[::-1]: # slice with step -1 reverses
print("Palindrome")
else:
print("Not a palindrome")
print(s.upper(), "|", s.title(), "|", len(s))
print(s[0], s[-1], s[2:5], s[:3], s[-3:])
print(s.count("s"), s.find("run"), s.find("xyz"), s.startswith("nu"))
print(s.split(), "-".join(["C", "B", "S", "E"]))
print(s.partition(" "), s.strip().isalpha(), "2024".isdigit())
Typed in: nurses run
Output (Python 3.12)
Enter a string: Vowels: 3
Palindrome
NURSES RUN | Nurses Run | 10
n n rse nur run
2 7 -1 True
['nurses', 'run'] C-B-S-E
('nurses', ' ', 'run') False True
The online compiler cannot read typed input yet: input() raises an error there. To run a program that asks for input, replace each input(...) with the value shown under "Typed in" — e.g. n = int("29") — then press Run. The output on this page was produced with those same values on Python 3.12.
CBSE expects: Build and modify lists (append, extend, insert, remove, pop, sort, reverse), use len/min/max/sum/sorted, traverse by index and by element, search linearly, handle a 2-D list.
Board-style program: Marks list: statistics, methods, linear search, a 2-D list
marks = [78, 92, 65, 88, 92, 71]
print("Total:", sum(marks), "Average:", sum(marks) / len(marks))
print("Highest:", max(marks), "Lowest:", min(marks))
marks.append(84) # add at the end
marks.insert(0, 90) # add at index 0
marks.remove(65) # remove first occurrence of a value
last = marks.pop() # remove and return the last item
print(marks, last)
print(marks.count(92), marks.index(88))
print(sorted(marks), marks[::-1], marks[1:4])
marks.sort(reverse=True) # in place
print(marks)
key = int(input("Enter marks to search: "))
found = False
for i in range(len(marks)): # linear search
if marks[i] == key:
print("Found at index", i)
found = True
break
if not found:
print("Not found")
table = [[1, 2, 3], [4, 5, 6]] # nested (2-D) list
for row in table:
for x in row:
print(x, end=" ")
print()
print(table[1][2])
Typed in: 88
Output (Python 3.12)
Total: 486 Average: 81.0
Highest: 92 Lowest: 65
[90, 78, 92, 88, 92, 71] 84
2 3
[71, 78, 88, 90, 92, 92] [71, 92, 88, 92, 78, 90] [78, 92, 88]
[92, 92, 90, 88, 78, 71]
Enter marks to search: Found at index 3
1 2 3
4 5 6
6
The online compiler cannot read typed input yet: input() raises an error there. To run a program that asks for input, replace each input(...) with the value shown under "Typed in" — e.g. n = int("29") — then press Run. The output on this page was produced with those same values on Python 3.12.
CBSE expects: Create tuples (including the one-element tuple), index and slice them, pack and unpack, use count/index/len/sorted/min/max/sum, and explain why item assignment fails.
Board-style program: Word frequency, then every dictionary method the syllabus names
sentence = input("Enter a sentence: ")
freq = {}
for word in sentence.split():
freq[word] = freq.get(word, 0) + 1 # get() avoids a KeyError
for word in sorted(freq):
print(word, ":", freq[word])
student = {"name": "Riya", "class": 11, "marks": 91}
student["section"] = "A" # add a key
student["marks"] = 95 # update a value
del student["class"] # delete a key
print(student)
print(list(student.keys()), list(student.values()))
for k, v in student.items():
print(k, "->", v)
print(student.get("roll", "not present"), len(student), "name" in student)
student.update({"roll": 7})
print(student.pop("section"), student.popitem())
print(dict.fromkeys(["a", "b"], 0), student.setdefault("house", "Red"))
Typed in: the cat and the dog and the bird
Output (Python 3.12)
Enter a sentence: and : 2
bird : 1
cat : 1
dog : 1
the : 3
{'name': 'Riya', 'marks': 95, 'section': 'A'}
['name', 'marks', 'section'] ['Riya', 95, 'A']
name -> Riya
marks -> 95
section -> A
not present 3 True
A ('roll', 7)
{'a': 0, 'b': 0} Red
The online compiler cannot read typed input yet: input() raises an error there. To run a program that asks for input, replace each input(...) with the value shown under "Typed in" — e.g. n = int("29") — then press Run. The output on this page was produced with those same values on Python 3.12.
8.Python modules: math, random, statistics
CBSE expects: Import a module with import and from ... import; use math (pi, e, sqrt, ceil, floor, pow, fabs, sin, cos, tan), random (random, randint, randrange) and statistics (mean, median, mode).
Digital footprint, netiquette, data protection, IPR, licensing, cyber crime and the IT Act, e-waste, and technology and society.
Not covered on PyRun: Theory only. PyRun does not cover this unit; there is nothing to run. Study it from the textbook and past papers.
Questions
Is PyRun enough to prepare for the CBSE Computer Science board exam?
No, not on its own. PyRun covers the Python part of Computer Science (083) and lets you practise the SQL queries. It does not teach the theory units (Computer Systems and Organisation and Society, Law and Ethics in Class 11; Computer Networks in Class 12) or the Python–MySQL connector, which needs MySQL on a real computer. Use your NCERT textbook and the curriculum and sample papers on https://cbseacademic.nic.in/ for the full syllabus, and PyRun to practise the programs.
Is it free?
These CBSE pages, the cheat sheets and the online Python compiler are free, with no account needed to press Run. The first 5 lessons are free; the lessons after that need a paid plan. Each topic on this page shows whether its lesson is free.
Can I practise on my phone without installing Python?
Yes. The compiler runs Python 3.12 inside the browser (Chrome or Safari on Android and iPhone). The first load downloads about 10 MB, then it is cached. One limit: it cannot read typed input yet, so replace each input() with the value you want before pressing Run. Files a program writes live in memory and disappear when you reload.
pyrun.in/cbse-python/class-11 · CBSE Class 11 Python · programs run on Python 3.12