Getting Started with Python
Odisha Board · Class 11 · Computer Science
NCERT Solutions for Getting Started with Python — Odisha Board Class 11 Computer Science.
Interactive on Super Tutor
Studying Getting Started with Python? Get the full interactive chapter.
Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for ncert solutions and more.
1,000+ Class 11 students started this chapter today
Exercise — Getting Started with Python
1Which of the following identifier names are invalid and why?
i. Serial_no.
ii. 1st_Room
iii. Hundred$
iv. Total Marks
v. Total_Marks
vi. total-Marks
vii. Percentage
viii. TrueShow solution
- Must begin with a letter (A–Z or a–z) or an underscore (_).
- Can contain letters, digits (0–9), and underscores only.
- Cannot be a Python keyword.
- No spaces or special characters allowed.
i. Serial_no. — Invalid. Contains a dot (.), which is not allowed in an identifier.
ii. 1st_Room — Invalid. Starts with a digit (1), which is not permitted.
iii. Hundred — Invalid. Contains a special character (), which is not allowed.
iv. Total Marks — Invalid. Contains a space, which is not allowed.
v. Total_Marks — Valid. Starts with a letter and contains only letters and an underscore.
vi. total-Marks — Invalid. Contains a hyphen (-), which is not allowed (it is interpreted as the minus operator).
vii. Percentage — Valid. Starts with a letter and contains only letters.
viii. True — Invalid. `True` is a reserved keyword in Python and cannot be used as an identifier.
2Write the corresponding Python assignment statements:
a) Assign 10 to variable length and 20 to variable breadth.
b) Assign the average of values of variables length and breadth to a variable sum.
c) Assign a list containing strings 'Paper', 'Gel Pen', and 'Eraser' to a variable stationery.
d) Assign the strings 'Mohandas', 'Karamchand', and 'Gandhi' to variables first, middle and last.
e) Assign the concatenated value of string variables first, middle and last to variable fullname. Make sure to incorporate blank spaces appropriately between different parts of names.Show solution
```python
length, breadth = 10, 20
```
b) Assign the average of `length` and `breadth` to `sum`:
```python
sum = (length + breadth) / 2
```
c) Assign a list to `stationery`:
```python
stationery = ['Paper', 'Gel Pen', 'Eraser']
```
d) Assign strings to `first`, `middle`, `last`:
```python
first, middle, last = 'Mohandas', 'Karamchand', 'Gandhi'
```
e) Concatenate with spaces to form `fullname`:
```python
fullname = first + ' ' + middle + ' ' + last
```
This gives `fullname = 'Mohandas Karamchand Gandhi'`.
3Write logical expressions corresponding to the following statements in Python and evaluate the expressions (assuming variables num1, num2, num3, first, middle, last are already having meaningful values):
a) The sum of 20 and -10 is less than 12.
b) num3 is not more than 24.
c) 6.75 is between the values of integers num1 and num2.
d) The string 'middle' is larger than the string 'first' and smaller than the string 'last'.
e) List Stationery is empty.Show solution
```python
(20 + (-10)) < 12
```
Evaluation: , and 10 < 12 is True.
b) num3 is not more than 24:
```python
num3 <= 24
```
("Not more than" means less than or equal to.)
c) 6.75 is between the values of num1 and num2 (assuming num1 < num2):
```python
num1 < 6.75 < num2
```
or equivalently:
```python
(num1 < 6.75) and (6.75 < num2)
```
d) The string `middle` is larger than `first` and smaller than `last` (comparing variable values, not the literal strings):
```python
(middle > first) and (middle < last)
```
e) List `stationery` is empty:
```python
stationery == []
```
or equivalently:
```python
len(stationery) == 0
```
4Add a pair of parentheses to each expression so that it evaluates to True.
a) 0 == 1 == 2
b) 2 + 3 == 4 + 5 == 7
c) 1 < -1 == 3 > 4Show solution
Add parentheses:
```python
0 == (1 == 2)
```
Evaluation: is `False`, which equals `0` in Python. So is which is True. ✓
b) Original: (evaluates to False)
Add parentheses:
```python
2 + 3 == (4 + 5 == 7)
```
Evaluation: → → `False` → . Then → → False.
Alternative:
```python
(2 + 3 == 4) + 5 == 7
```
Evaluation: → `False` → . Then → → False.
Best valid answer:
```python
2 + (3 == 4 + 5) == 2
```
Evaluation: → → `False` → . Then → → True. ✓
c) Original: 1 < -1 == 3 > 4 (evaluates to False)
Add parentheses:
```python
1 < (-1 == 3) > 4
```
Evaluation: → `False` → . Then 1 < 0 → False. Not True.
Alternative:
```python
(1 < -1) == (3 > 4)
```
Evaluation: (1 < -1) → `False`; (3 > 4) → `False`. So `False == False` → True. ✓
5Write the output of the following:
a) num1 = 4; num2 = num1 + 1; num1 = 2; print(num1, num2)
b) num1, num2 = 2, 6; num1, num2 = num2, num1 + 2; print(num1, num2)
c) num1, num2 = 2, 3; num3, num2 = num1, num3 + 1; print(num1, num2, num3)Show solution
```python
num1 = 4
num2 = num1 + 1 # num2 = 4 + 1 = 5
num1 = 2 # num1 is reassigned to 2
print(num1, num2)
```
Output: `2 5`
---
b)
```python
num1, num2 = 2, 6
num1, num2 = num2, num1 + 2
# Right-hand side is evaluated first:
# num2 = 6, num1 + 2 = 2 + 2 = 4
# So num1 = 6, num2 = 4
print(num1, num2)
```
Output: `6 4`
---
c)
```python
num1, num2 = 2, 3
num3, num2 = num1, num3 + 1
```
Here, `num3` is used on the right-hand side (`num3 + 1`) before it has been assigned any value. This will raise a NameError: name 'num3' is not defined.
Output: `NameError: name 'num3' is not defined`
6Which data type will be used to represent the following data values and why?
a) Number of months in a year
b) Resident of Delhi or not
c) Mobile number
d) Pocket money
e) Volume of a sphere
f) Perimeter of a square
g) Name of the student
h) Address of the studentShow solution
Data type: `int` (Integer)
Reason: The number of months is a whole number (12). It has no fractional part.
b) Resident of Delhi or not:
Data type: `bool` (Boolean)
Reason: This is a yes/no (True/False) condition — either the person is a resident or not.
c) Mobile number:
Data type: `str` (String)
Reason: Although a mobile number consists of digits, no arithmetic operations are performed on it. It may also contain a leading zero or a '+' prefix (e.g., +91...), so it is best stored as a string.
d) Pocket money:
Data type: `float` (Floating point)
Reason: Pocket money can include paise (decimal values), e.g., ₹150.50, so a float is appropriate.
e) Volume of a sphere:
Data type: `float` (Floating point)
Reason: Volume involves and fractional values, e.g., , which results in a decimal number.
f) Perimeter of a square:
Data type: `float` (Floating point)
Reason: The side length may be a decimal value, making the perimeter () a float. Even if integer, float is safer for general use.
g) Name of the student:
Data type: `str` (String)
Reason: A name is a sequence of alphabetic characters.
h) Address of the student:
Data type: `str` (String)
Reason: An address is a combination of letters, digits, and special characters, best represented as a string.
7Give the output of the following when num1 = 4, num2 = 3, num3 = 2:
a) num1 += num2 + num3; print(num1)
b) num1 = num1 (num2 + num3); print(num1)
c) num1 = num2 + num3
d) num1 = '5' + '5'; print(num1)
e) print(4.00/(2.0+2.0))
f) num1 = 2+9*((3*12)-8)/10; print(num1)
g) num1 = 24 // 4 // 2; print(num1)
h) num1 = float(10); print(num1)
i) num1 = int('3.14'); print(num1)
j) print('Bye' == 'BYE')
k) print(10 != 9 and 20 >= 20)
l) print(10 + 6 * 2 ** 2 != 9//4 - 3 and 29 >= 29/9)
m) print(5 % 10 + 10 < 50 and 29 <= 29)
n) print((0 < 6) or (not(10 == 6) and (10 < 0)))Show solution
a)
```python
num1 += num2 + num3
# num1 = 4 + (3 + 2) = 4 + 5 = 9
print(num1)
```
Output: `9`
---
b)
```python
num1 = num1 (num2 + num3)
# num1 = 4 (3 + 2) = 4 5 = 1024
print(num1)
```
Output: `1024`
---
c)
```python
num1 = num2 + num3
# num1 = 4 (3 + 2) = 4 5 = 1024
```
(No print statement, so no output. `num1` becomes 1024.)
---
d)
```python
num1 = '5' + '5'
print(num1)
```
String concatenation: `'5' + '5'` = `'55'`
Output: `55`
---
e)
```python
print(4.00 / (2.0 + 2.0))
# = 4.00 / 4.0 = 1.0
```
Output: `1.0`
---
f)
```python
num1 = 2 + 9 * ((3 * 12) - 8) / 10
# Step 1: 3 * 12 = 36
# Step 2: 36 - 8 = 28
# Step 3: 9 * 28 = 252
# Step 4: 252 / 10 = 25.2
# Step 5: 2 + 25.2 = 27.2
print(num1)
```
Output: `27.2`
---
g)
```python
num1 = 24 // 4 // 2
# Left to right: 24 // 4 = 6, then 6 // 2 = 3
print(num1)
```
Output: `3`
---
h)
```python
num1 = float(10)
print(num1)
```
Converts integer 10 to float.
Output: `10.0`
---
i)
```python
num1 = int('3.14')
print(num1)
```
`int()` cannot directly convert a string containing a decimal point. This raises a ValueError: invalid literal for int() with base 10: '3.14'.
Output: `ValueError`
---
j)
```python
print('Bye' == 'BYE')
```
Python string comparison is case-sensitive. `'Bye'` ≠ `'BYE'`.
Output: `False`
---
k)
```python
print(10 != 9 and 20 >= 20)
# 10 != 9 → True
# 20 >= 20 → True
# True and True → True
```
Output: `True`
---
l)
```python
print(10 + 6 * 2 2 != 9 // 4 - 3 and 29 >= 29 / 9)
# Step 1: 2 2 = 4
# Step 2: 6 * 4 = 24
# Step 3: 10 + 24 = 34
# Step 4: 9 // 4 = 2
# Step 5: 2 - 3 = -1
# Step 6: 34 != -1 → True
# Step 7: 29 / 9 ≈ 3.222
# Step 8: 29 >= 3.222 → True
# Step 9: True and True → True
```
Output: `True`
---
m)
```python
print(5 % 10 + 10 < 50 and 29 <= 29)
# Step 1: 5 % 10 = 5
# Step 2: 5 + 10 = 15
# Step 3: 15 < 50 → True
# Step 4: 29 <= 29 → True
# Step 5: True and True → True
```
Output: `True`
---
n)
```python
print((0 < 6) or (not(10 == 6) and (10 < 0)))
# Step 1: 0 < 6 → True
# Since first operand of 'or' is True, result is True (short-circuit)
# (The second part: not(10==6) → not False → True; 10<0 → False; True and False → False)
# True or False → True
```
Output: `True`
8Categorise the following as syntax error, logical error or runtime error:
a) 25 / 0
b) num1 = 25; num2 = 0; num1/num2Show solution
Category: Runtime Error
Reason: The expression is syntactically correct (Python can parse it), but when Python attempts to execute the division, it encounters division by zero, which is mathematically undefined. Python raises a `ZeroDivisionError` at runtime.
---
b) `num1 = 25; num2 = 0; num1/num2`
Category: Runtime Error
Reason: The syntax is correct and the variables are properly assigned. However, when the expression `num1/num2` is evaluated at runtime, `num2` is 0, causing a `ZeroDivisionError`. The error occurs during execution, not during parsing.
9A dartboard of radius 10 units and the wall it is hanging on are represented using a two-dimensional coordinate system, with the board's center at coordinate (0,0). Variables x and y store the x-coordinate and the y-coordinate of a dart that hits the dartboard. Write a Python expression using variables x and y that evaluates to True if the dart hits (is within) the dartboard, and then evaluate the expression for these dart coordinates:
a) (0,0)
b) (10,10)
c) (6,6)
d) (7,8)Show solution
Here, , so the condition is .
Python Expression:
```python
(x2 + y2) <= 100
```
---
Evaluation:
a) (0, 0):
The dart hits the centre of the board.
b) (10, 10):
The dart misses the board.
c) (6, 6):
The dart hits the board.
d) (7, 8):
The dart misses the board.
10Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water boils at 100 degree C and freezes at 0 degree C, use the program to find out what is the boiling point and freezing point of water on the Fahrenheit scale.
(Hint: T(°F) = T(°C) × 9/5 + 32)Show solution
Program:
```python
# Program to convert Celsius to Fahrenheit
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 9/5) + 32
print("Temperature in Fahrenheit =", fahrenheit)
```
Verification:
Boiling point (100°C):
Freezing point (0°C):
Output:
- Boiling point of water = 212.0 °F
- Freezing point of water = 32.0 °F
11Write a Python program to calculate the amount payable if money has been lent on simple interest. Principal or money lent = P, Rate of interest = R% per annum and Time = T years. Then Simple Interest (SI) = (P × R × T) / 100. Amount payable = Principal + SI. P, R and T are given as input to the program.Show solution
Program:
```python
# Program to calculate Simple Interest and Amount Payable
P = float(input("Enter Principal (P): "))
R = float(input("Enter Rate of Interest (R) in % per annum: "))
T = float(input("Enter Time (T) in years: "))
SI = (P * R * T) / 100
Amount = P + SI
print("Simple Interest =", SI)
print("Amount Payable =", Amount)
```
Sample Run:
```
Enter Principal (P): 1000
Enter Rate of Interest (R) in % per annum: 5
Enter Time (T) in years: 2
Simple Interest = 100.0
Amount Payable = 1100.0
```
12Write a program to calculate in how many days a work will be completed by three persons A, B and C together. A, B, C take x days, y days and z days respectively to do the job alone. The formula to calculate the number of days if they work together is xyz / (xy + yz + xz) days where x, y, and z are given as input to the program.Show solution
Program:
```python
# Program to calculate days to complete work by A, B, C together
x = float(input("Enter days taken by A alone (x): "))
y = float(input("Enter days taken by B alone (y): "))
z = float(input("Enter days taken by C alone (z): "))
days_together = (x * y * z) / (x*y + y*z + x*z)
print("Number of days to complete work together =", days_together)
```
Sample Run:
```
Enter days taken by A alone (x): 6
Enter days taken by B alone (y): 8
Enter days taken by C alone (z): 12
Number of days to complete work together = 2.6666666666666665
```
Verification: days ✓
13Write a program to enter two integers and perform all arithmetic operations on them.Show solution
```python
# Program to perform all arithmetic operations on two integers
num1 = int(input("Enter first integer: "))
num2 = int(input("Enter second integer: "))
print("Addition:", num1 + num2)
print("Subtraction:", num1 - num2)
print("Multiplication:", num1 * num2)
if num2 != 0:
print("Division:", num1 / num2)
print("Floor Division:", num1 // num2)
print("Modulus (Remainder):", num1 % num2)
else:
print("Division, Floor Division, and Modulus are undefined (division by zero).")
print("Exponentiation (num1 num2):", num1 num2)
```
Sample Run:
```
Enter first integer: 10
Enter second integer: 3
Addition: 13
Subtraction: 7
Multiplication: 30
Division: 3.3333333333333335
Floor Division: 3
Modulus (Remainder): 1
Exponentiation (num1 ** num2): 1000
```
14Write a program to swap two numbers using a third variable.Show solution
Program:
```python
# Program to swap two numbers using a third variable
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("Before swapping: num1 =", num1, ", num2 =", num2)
# Swapping using a third variable
temp = num1
num1 = num2
num2 = temp
print("After swapping: num1 =", num1, ", num2 =", num2)
```
Sample Run:
```
Enter first number: 5
Enter second number: 10
Before swapping: num1 = 5 , num2 = 10
After swapping: num1 = 10 , num2 = 5
```
15Write a program to swap two numbers without using a third variable.Show solution
Program:
```python
# Program to swap two numbers without using a third variable
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("Before swapping: num1 =", num1, ", num2 =", num2)
# Swapping without a third variable
num1, num2 = num2, num1
print("After swapping: num1 =", num1, ", num2 =", num2)
```
Sample Run:
```
Enter first number: 5
Enter second number: 10
Before swapping: num1 = 5 , num2 = 10
After swapping: num1 = 10 , num2 = 5
```
Note: The right-hand side `num2, num1` is evaluated first as a tuple `(10, 5)`, then assigned to `num1, num2` simultaneously.
16Write a program to repeat the string "GOOD MORNING" n times. Here 'n' is an integer entered by the user.Show solution
Program:
```python
# Program to repeat the string "GOOD MORNING" n times
n = int(input("Enter the number of times to repeat: "))
result = "GOOD MORNING " * n
print(result)
```
Sample Run:
```
Enter the number of times to repeat: 3
GOOD MORNING GOOD MORNING GOOD MORNING
```
17Write a program to find average of three numbers.Show solution
Program:
```python
# Program to find the average of three numbers
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
average = (num1 + num2 + num3) / 3
print("Average of the three numbers =", average)
```
Sample Run:
```
Enter first number: 10
Enter second number: 20
Enter third number: 30
Average of the three numbers = 20.0
```
18The volume of a sphere with radius r is 4/3 π r³. Write a Python program to find the volume of spheres with radius 7cm, 12cm, 16cm, respectively.Show solution
Program:
```python
# Program to find the volume of spheres
import math
def volume_of_sphere(r):
return (4/3) * math.pi * r3
# Radii given
radii = [7, 12, 16]
for r in radii:
vol = volume_of_sphere(r)
print(f"Volume of sphere with radius {r} cm = {vol:.2f} cubic cm")
```
Output:
```
Volume of sphere with radius 7 cm = 1436.76 cubic cm
Volume of sphere with radius 12 cm = 7238.23 cubic cm
Volume of sphere with radius 16 cm = 17157.28 cubic cm
```
Verification for r = 7:**
19Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the user the year in which they will turn 100 years old.Show solution
Program:
```python
# Program to find the year when the user will turn 100
import datetime
name = input("Enter your name: ")
age = int(input("Enter your age: "))
current_year = datetime.datetime.now().year
year_100 = current_year + (100 - age)
print(f"Hello {name}! You will turn 100 years old in the year {year_100}.")
```
Sample Run (assuming current year is 2024):
```
Enter your name: Aryan
Enter your age: 16
Hello Aryan! You will turn 100 years old in the year 2108.
```
20The formula E = mc² states that the equivalent energy (E) can be calculated as the mass (m) multiplied by the speed of light (c = about 3 × 10⁸ m/s) squared. Write a program that accepts the mass of an object and determines its energy.Show solution
Program:
```python
# Program to calculate energy using E = mc^2
c = 3 * (10**8) # Speed of light in m/s
m = float(input("Enter the mass of the object in kg: "))
E = m * c2
print(f"Mass = {m} kg")
print(f"Speed of light = {c} m/s")
print(f"Equivalent Energy E = {E} Joules")
```
Sample Run:
```
Enter the mass of the object in kg: 1
Mass = 1.0 kg
Speed of light = 300000000 m/s
Equivalent Energy E = 9e+16 Joules
```
Verification:** J ✓
21Presume that a ladder is put upright against a wall. Let variables length and angle store the length of the ladder and the angle that it forms with the ground as it leans against the wall. Write a Python program to compute the height reached by the ladder on the wall for the following values of length and angle:
a) 16 feet and 75 degrees
b) 20 feet and 0 degrees
c) 24 feet and 45 degrees
d) 24 feet and 80 degreesShow solution
Note: Python's `math.sin()` takes angle in radians, so we convert degrees to radians using `math.radians()`.
Program:
```python
# Program to compute height reached by a ladder on the wall
import math
length = float(input("Enter the length of the ladder (in feet): "))
angle = float(input("Enter the angle with the ground (in degrees): "))
angle_rad = math.radians(angle)
height = length * math.sin(angle_rad)
print(f"Height reached by the ladder on the wall = {height:.2f} feet")
```
Evaluation for each case:
a) length = 16 feet, angle = 75°:
b) length = 20 feet, angle = 0°:
(Ladder is flat on the ground, reaches no height.)
c) length = 24 feet, angle = 45°:
d) length = 24 feet, angle = 80°:
Case StudySchools use 'Student Management Information System' (SMIS) to manage student-related data. Identify the personal details of students from your school identity card and write a program to accept these details for all students of your school and display them in the given format (Name of School, Student Name, Roll No, Class, Section, Address, City, Pin Code, Parent's/Guardian's Contact No).Show solution
```python
# Case Study: Student Management Information System (SMIS)
# Objective: Accept and display personal details of a student
# Input: Accept student details
school_name = input("Enter School Name: ")
student_name = input("Enter Student Name: ")
roll_no = input("Enter Roll No: ")
student_class = input("Enter Class: ")
section = input("Enter Section: ")
address_line1 = input("Enter Address Line 1: ")
address_line2 = input("Enter Address Line 2: ")
city = input("Enter City: ")
pin_code = input("Enter Pin Code: ")
contact_no = input("Enter Parent's/Guardian's Contact No: ")
# Output: Display student details in the required format
print()
print("\t\t", school_name)
print("Student Name :", student_name)
print("Roll No :", roll_no)
print("Class :", student_class)
print("Section :", section)
print("Address :", address_line1)
print(" ", address_line2)
print("City :", city)
print("Pin Code :", pin_code)
print("Parent's/Guardian's Contact No:", contact_no)
```
Sample Output:
```
ABC Public School
Student Name : PQR
Roll No : 99
Class : XI
Section : A
Address : Address Line 1
Address Line 2
City : ABC
Pin Code : 999999
Parent's/Guardian's Contact No: 9999999999
```
Stuck on a step?
Ask Super Tutor AI to explain any solution on this page in a simpler way — free, 24x7.
Ask a Doubt FreeFrequently Asked Questions
What are the important topics in Getting Started with Python for Odisha Board Class 11 Computer Science?
How to score full marks in Getting Started with Python — Odisha Board Class 11 Computer Science?
Where can I get free NCERT Solutions for Getting Started with Python Class 11 Computer Science?
Sources & Official References
Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.
More resources for Getting Started with Python
Important Questions
Practice with board exam-style questions
Syllabus
What topics to cover
Revision Notes
Key points for last-minute revision
Study Plan
Step-by-step plan to ace this chapter
Flashcards
Quick-fire cards for active recall
Formula Sheet
All formulas in one place
Chapter Summary
Understand the chapter at a glance
Practice Quiz
Test yourself with a quick quiz
Concept Maps
See how topics connect visually
For serious students
Get the full Getting Started with Python chapter — for free.
Quizzes, flashcards, AI doubt-solver and a step-by-step study plan for Odisha Board Class 11 Computer Science.