Getting Started With Python

This page contains the NCERT Computer Science class 11 chapter 5 Getting Started with Python. You can find the solutions for the chapter 5 of NCERT class 11 Computer Science Exercise. So is the case if you are looking for NCERT class 11 Computer Science related topic Getting Started with Python questions and answers for the Exercise
Exercise
1. Which of the following identifier names are invalid and why?
i
Serial_no.
v
Total_Marks
ii
1st_Room
vi
total-Marks
iii
Hundred$
vii
_Percentage
iv
Total Marks
viii
True
The identification of whether the given identifier is valid or not along with the reason is given below.
S.No.
Identifier Name
Validity
Reason
a)
Serial_no.
❌ Invalid
Identifier cannot use special symbols like !, @, # $, %, etc. This identifier has ‘.’ (period/full-stop) in its name. So, it is invalid.
b)
1st_Room
❌ Invalid
An identifer can only start with an alphabet(upper/lower case) or an underscore sign ( _ ). It cannot start with a digit. Note that it can contain a digit as part of the name. But it can not start with a digit.
c)
Serial_no
✔ valid
d)
total Marks
❌ Invalid
Identifier cannot use special symbols like !, @, # $, %, etc. This identifier has ‘ ‘ (space) in its name. So, it is invalid.
e)
Total_Marks
✔ valid
f)
total-Marks
❌ Invalid
Identifier cannot use special symbols like !, @, # $, %, etc. This identifier has ‘-‘ (hiphen/minus) in its name. So, it is invalid. Also note that the identifier can have an underscore which is different from hiphen/minus.
g)
_Percentage
✔ valid
h)
True
❌ Invalid
The variable name can not be a keyword reserved in Python. We know that True is a reserved keyword. So, it cannot be used as a variable name.
2. Write 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.
a) Assign 10 to variable length and 20 to variable breadth.
# Assign values to length and breadth
length = 10
breadth = 20
OR the following statement can also be used:
length, breadth = 10, 20
b) Assign the average of values of variables length and breadth to a variable sum.
# Compute average of length and breadth and store in sum
sum = (length + breadth) / 2
c) Assign a list containing strings ‘Paper’, ‘Gel Pen’ and ‘Eraser’ to a variable stationery.
# Create a list of stationery items
stationery = ['Paper', 'Gel Pen', 'Eraser']
d) Assign the strings ‘Mohandas’, ‘Karamchand’, and ‘Gandhi’ to variables first, middle and last.
# Assign parts of a name into variables
first = 'Mohandas'
middle = 'Karamchand'
last = 'Gandhi'
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.
# Concatenate name parts into a full name with spaces
fullname = first + ' ' + middle + ' ' + last
Or the folloing statement can also be used:
first, middle, last = 'Mohandas', 'Karamchand', 'Gandhi'
3. Write 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.
(For evaluation, I’m assuming: `num1 = 4`, `num2 = 10`, `num3 = 24`, `first = "A"`, `middle = "M"`, `last = "Z"`, `stationery = []`.)
a) The sum of 20 and –10 is less than 12.
Expression:
(20 + (-10)) < 12
Evaluation: `10 < 12`True
b) num3 is not more than 24.
Expression:
not (num3 > 24)
# or simply: num3 <= 24
Evaluation (num3 = 24): `24 <= 24`True
c) 6.75 is between the values of integers num1 and num2.
Expression:
(num1 < 6.75 < num2) or (num2 < 6.75 < num1)
Evaluation (num1=4, num2=10): `4 < 6.75 < 10`True
d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string ‘last’.
Expression:
first < middle < last
Evaluation (“A” < “M” < “Z”)True
e) List Stationery is empty.
Expression:
stationery == []
# or: len(stationery) == 0
Evaluation (stationery = []): True
4. Add 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 > 4
a) `0 == 1 == 2`
0 == (1 == 2)
Because `(1 == 2)` is `False`, and `0 == False` is `True`.
b) `2 + 3 == 4 + 5 == 7`
2 + (3 == 4) + 5 == 7
Because `(3 == 4)` is `False` (i.e., 0), so `2 + 0 + 5 == 7` → True.
c) `1 < -1 == 3 > 4`
(1 < -1) == (3 > 4)
Both sides are `False`, so `False == False` → True.
5. Write 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)
a)
num1 = 4
num2 = num1 + 1
num1 = 2
print(num1, num2)
Output:
2 5
b)
num1, num2 = 2, 6
num1, num2 = num2, num1 + 2
print(num1, num2)
Output:
6 4
c)
num1, num2 = 2, 3
num3, num2 = num1, num3 + 1
print(num1, num2, num3)
Output:
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'num3' is not defined
6. Which 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 student
Data value
Suitable data type
Why?
(a) Number of months in a year
`int`
It is a whole number (12).
(b) Resident of Delhi or not
`bool`
It has only two possible values: `True` or `False`.
(c) Mobile number
`str`
We don’t do calculations on it, and it may include leading 0 or +91, so storing as text is safer.
(d) Pocket money
`float`
It can have decimal values (like ₹50.50).
(e) Volume of a sphere
`float`
The result is usually in decimals because it involves π.
(f) Perimeter of a square
`float`
It can be decimal if the side length is decimal.
(g) Name of the student
`str`
A name is text (characters).
(h) Address of the student
`str`
Address is also text (characters, spaces, etc.).
7. Give 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)
((0 < 6) or (not(10 == 6) and (10<0)))
a)
num1 += num2 + num3
print(num1)
Output:
9
b)
num1 = num1 ** (num2 + num3)
print(num1)
Output:
1024
c)
num1 **= num2 + num3
Result: `num1` becomes `1,024`
d)
num1 = '5' + '5'
print(num1)
Output:
55
e)
print(4.00/(2.0+2.0))
Output:
1.0
f)
num1 = 2+9*((3*12)-8)/10
print(num1)
Output:
27.2
g)
num1 = 24 // 4 // 2
print(num1)
Output:
3
h)
num1 = float(10)
print(num1)
Output:
10.0
i)
num1 = int('3.14')
print(num1)
Output:
Error → ValueError (string '3.14' is not an integer)
j)
print('Bye' == 'BYE')
Output:
False
k)
print(10 != 9 and 20 >= 20)
Output:
True
l)
print(10 + 6 * 2 ** 2 != 9//4 -3 and 29 >= 29/9)
Output:
True
8. Categorise the following as syntax error, logical error or runtime error:
a)
25 / 0
b)
num1 = 25; num2 = 0; num1/num2
a) `25 / 0` → Runtime error
Error:
Traceback (most recent call last):
  File "", line 1, in 
ZeroDivisionError: division by zero
b) `num1 = 25; num2 = 0; num1/num2` → Runtime error
Error:
Traceback (most recent call last):
  File "", line 1, in 
ZeroDivisionError: division by zero
9. A 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)
Concept / Condition
A point hits the dartboard if its distance from the center (0, 0) is less than or equal to 10.
So we use:
{x^2 + y^2 ≤ 10^2}
Python Expression
x**2 + y**2 <= 10**2
(a) Evaluation of (0, 0)
x = 0, y = 0
x**2 + y**2 <= 10**2 # True (Hit)

Output:
True
Explanation:
0^2 + 0^2 = 0 \le 100 \Rightarrow \text{True (Hit)}
(b) Evaluation of (10, 10)
x = 10, y = 10
x**2 + y**2 <= 10**2 # False (Miss)
Output:
False
Explanation:
10^2 + 10^2 = 200 \le 100 \Rightarrow \text{False (Miss)}
(c) Evaluation of (6, 6)
x = 6, y = 6
x**2 + y**2 <= 10**2 # True (Hit)
Output:
True
Explanation:
6^2 + 6^2 = 72 \le 100 \Rightarrow \text{True (Hit)}
(d) Evaluation of (7, 8)
x = 7, y = 8
x**2 + y**2 <= 10**2 # False (Miss)
Output:
False
Explanation:
7^2 + 8^2 = 113 \le 100 \Rightarrow \text{False (Miss)}
x**2 + y**2 <= 10**2
10. Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water boils at 100 degree C and freezes as 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) × \dfrac{9}{5} + 32}
# Celsius to Fahrenheit
c = float(input("Enter temperature in °C: "))
f = c * 9/5 + 32
print("Temperature in °F =", f)
Sample run to find the boiling point of water in Fahrenheit (Convert 100° C to Fahrenheit):
Enter temperature in °C: 100
Temperature in °F = 212.0
Sample run to find the freezing point of water in Fahrenheit (Convert 0° C to Fahrenheit):
Enter temperature in °C: 0
Temperature in °F = 32.0
11. Write 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 x R x T)/ 100.
Amount payable = Principal + SI.
P, R and T are given as input to the program.
# Calculate simple interest (SI) and the total amount payable
P = float(input("Enter Principal (P): "))
R = float(input("Enter Rate (R) in % per annum: "))
T = float(input("Enter Time (T) in years: "))

# Calculation of Simple Interest
SI = (P * R * T) / 100
# Amount is sum of Principal and Simple Interest.
amount = P + SI

# Print the computed values:
print("Simple Interest =", SI)
print("Amount payable =", amount)
Sample run output:
Enter Principal (P): 100000
Enter Rate (R) in % per annum: 8.5
Enter Time (T) in years: 3

Simple Interest = 25500.0
Amount payable = 125500.0
12. Write 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.
# Compute days required when A, B and C work together using formula xyz/(xy+yz+xz)
x = float(input("Days taken by A alone (x): "))
y = float(input("Days taken by B alone (y): "))
z = float(input("Days taken by C alone (z): "))

# Calculation: Using the combined work-rate formula
# This formula is derived from (1/x + 1/y + 1/z) = 1/TotalDays
days = (x * y * z) / (x*y + y*z + x*z)

# Output: Display the result of the calculation
print("Days to complete work together =", days)
Sample Run Output:
Days taken by A alone (x): 10
Days taken by B alone (y): 15
Days taken by C alone (z): 30

Days to complete work together = 5.0
13. Write a program to enter two integers and perform all arithmetic operations on them.
# Read two integers and show results for common arithmetic operations

a = int(input("Enter first integer (a): "))
b = int(input("Enter second integer (b): "))

# Addition
print("a + b =", a + b)

# Subtraction
print("a - b =", a - b)

# Multiplication
print("a * b =", a * b)

# Division-related operations need b != 0
if b != 0:
    # True division (gives decimal result)
    print("a / b =", a / b)

    # Floor division (quotient without decimal part)
    print("a // b =", a // b)

    # Modulus (remainder)
    print("a % b =", a % b)
else:
    print("a / b = Not possible (division by zero)")
    print("a // b = Not possible (division by zero)")
    print("a % b = Not possible (division by zero)")

# Exponentiation (a raised to the power b)
print("a ** b =", a ** b)
Sample Run Output
Enter first integer (a): 10
Enter second integer (b): 3
a + b = 13
a - b = 7
a * b = 30
a / b = 3.3333333333333335
a // b = 3
a % b = 1
a ** b = 1000
14. Write a program to swap two numbers using a third variable.
# Program to swap the values of two variables using a temporary storage
# This ensures that no data is lost during the transfer.

# 1. Take input from the user for two variables
a = int(input("Enter first number (a): "))
b = int(input("Enter second number (b): "))

# 2. Use a temporary variable 'temp' to hold the value of 'a'
# Without this, assigning b to a would overwrite a's original value.
temp = a

# 3. Now that 'a' is safely backed up in 'temp', we can overwrite 'a' with 'b'
a = b

# 4. Finally, move the original value of 'a' (stored in 'temp') into 'b'
b = temp

# 5. Display the swapped results
print("\n--- After Swapping ---")
print("Value of a:", a)
print("Value of b:", b)
Sample Run Output
Enter first number (a): 50000
Enter second number (b): 125000

--- After Swapping ---
Value of a: 125000
Value of b: 50000
15. Write a program to swap two numbers without using a third variable.
# Program to swap two numbers using Python's tuple unpacking
# This is the most efficient and "Pythonic" method.

# 1. Take input from the user
a = int(input("Enter first number (a): "))
b = int(input("Enter second number (b): "))

# 2. Perform the swap in a single line
# This creates a temporary tuple (b, a) and then unpacks it back into a and b
a, b = b, a

# 3. Display the results
print("\n--- After Swapping (The Pythonic Way) ---")
print("Value of a:", a)
print("Value of b:", b)
Sample Run Output
Enter first number (a): 75000
Enter second number (b): 25000

--- After Swapping without temp variable ---
Value of a: 25000
Value of b: 75000
16. Write a program to repeat the string ‘‘GOOD MORNING” n times. Here ‘n’ is an integer entered by the user.
# Program to repeat the string "GOOD MORNING" n times (only if n > 0)

n = int(input("Enter the value of n: "))

# Check whether n is a positive integer
if n > 0:
    # Print "GOOD MORNING" on a new line, repeated n times
    print(("GOOD MORNING\n") * n)
else:
    # If n is 0 or negative, repetition doesn't make sense
    print("Please enter a positive integer (n > 0).")
Sample Run Output
Enter the value of n: 5
GOOD MORNING
GOOD MORNING
GOOD MORNING
GOOD MORNING
GOOD MORNING
17. Write a program to find average of three numbers.
# Program to find the average of three numbers

# Input three numbers from the user
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
c = float(input("Enter third number: "))

# Calculate average (sum of three numbers divided by 3)
avg = (a + b + c) / 3

# Display the result
print("Average =", avg)
Sample Run Output
Enter first number: 4500
Enter second number: 5500
Enter third number: 8000
Average = 6000.0
18. The 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.
# Program to find the volume of spheres with radii 7 cm, 12 cm and 16 cm
# Formula: V = (4/3) * pi * r^3

import math  # For using the value of pi (π)

# Declare radii separately (no list/array used)
r1 = 7
r2 = 12
r3 = 16

# Volume for radius 7 cm
v1 = (4/3) * math.pi * (r1 ** 3)
print("Radius =", r1, "cm -> Volume =", v1, "cm³")

# Volume for radius 12 cm
v2 = (4/3) * math.pi * (r2 ** 3)
print("Radius =", r2, "cm -> Volume =", v2, "cm³")

# Volume for radius 16 cm
v3 = (4/3) * math.pi * (r3 ** 3)
print("Radius =", r3, "cm -> Volume =", v3, "cm³")
Sample Run Output
Radius = 7 cm -> Volume = 1436.755040241732 cm³
Radius = 12 cm -> Volume = 7238.229473870882 cm³
Radius = 16 cm -> Volume = 17157.284678851496 cm³
19. Write 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.
import datetime  # Module used to fetch the current system date

# Fetch the current year from the system clock
current_year = datetime.datetime.now().year

# Input: Birth year from the user
birth_year = int(input("Enter your birth year: "))

# Calculation: Subtracting birth year from the current system year
age = current_year - birth_year

# Output: Displaying results using comma separation
# Note: Python automatically adds a space where the commas are placed
print("Current Year:", current_year)
print("Your age is:", age, "years")
Sample Run Output
Enter your name: Rahul
Enter your current age: 16
Current Year: 2026
Hello Rahul you will turn 100 years old in the year 2110
ℹ️ Note: The current year might change depending on the year in which you’re running this program. Also, the year in which the user reaches 100 years will also change in the run output of the program.
20. The 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.
# Program to calculate energy using Einstein's formula E = mc^2

# Speed of light in m/s (given in the question)
c = 3 * (10 ** 8)

# Input mass from the user (in kilograms)
m = float(input("Enter mass (in kg): "))

# Calculate energy (E) in joules
E = m * (c ** 2)

# Display the result
print("Energy (E) =", E, "joules")
Sample Run Output
Enter mass (in kg): 2
Energy (E) = 1.8e+17 joules
21. Presume 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 degrees
Ground Wall Ladder (length) Height (h) θ B T h = length × sin(θ)
# Program to calculate the height reached by a ladder leaning against a wall

import math  # for sin() and radians()

# Input ladder length and angle from user
length = float(input("Enter the length of the ladder: "))
angle = float(input("Enter the angle with the ground (in degrees): "))

# Basic validation
if length <= 0:
    print("Length should be greater than 0.")
elif angle < 0 or angle > 90:
    print("Angle should be between 0 and 90 degrees.")
else:
    # Convert angle from degrees to radians (because math.sin uses radians)
    angle_in_radians = math.radians(angle)

    # Height reached on the wall
    height = length * math.sin(angle_in_radians)

    # Display result
    print("Height reached on the wall =", round(height, 2))
Sample Output Run for Case (a): 16 feet and 75 degrees
Enter the length of the ladder: 16
    Enter the angle with the ground (in degrees): 75
    Height reached on the wall = 15.45
Sample Output Run for Case (b): 20 feet and 0 degrees
(Note: At 0°, the ladder is lying flat on the ground.)
Enter the length of the ladder: 20
Enter the angle with the ground (in degrees): 0
Height reached on the wall = 0.0
Sample Output Run for Case (c): 24 feet and 45 degrees
Enter the length of the ladder: 24
Enter the angle with the ground (in degrees): 45
Height reached on the wall = 16.97
Sample Output Run for Case (d): 24 feet and 80 degrees
Enter the length of the ladder: 24
Enter the angle with the ground (in degrees): 80
Height reached on the wall = 23.64
Analysis of Results
Case
Length (ft)
Angle (°)
Height Reached (ft)
Logic Check
a
16
75°
15.45
High angle, reaches near the top.
b
20
0.0
Flat on ground; height is zero.
c
24
45°
16.97
Moderate reach.
d
24
80°
23.64
Very steep; almost reaches full length.
⚠ Important Coding Note
The use of `math.radians(angle)` is critical here. In mathematics:
If you forget to convert, `math.sin(75)` would treat 75 as a radian value, leading to a mathematically incorrect height (and potentially a negative number!).
Case Study-based Question (SMIS)
Case Study-based Question
Schools use “Student Management Information System” (SMIS) to manage student-related data. This system provides facilities for:
recording and maintaining personal details of students.
maintaining marks scored in assessments and computing results of students.
keeping track of student attendance.
managing many other student-related data. Let us automate this process step by step.
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 following format.
Name of 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

# SMIS: Student Management Information System
# Width is strictly 62: | (1) + Inner Content (60) + | (1)

# Constants for fixed layout
WIDTH = 62
INNER = 60 

def border_line():
    """Prints the top and bottom borders (+ and 60 dashes)."""
    # Logic: 1 (+) + 60 (-) + 1 (+) = 62
    print("+" + "-" * INNER + "+")

def empty_line():
    """Prints a blank line with side borders for spacing."""
    # Logic: 1 (|) + 60 (spaces) + 1 (|) = 62
    print("|" + " " * INNER + "|")

def left_line(text):
    """Prints a line of text aligned to the left side."""
    # Truncate text to 60 if it's too long
    content = text[:INNER]
    # Calculate exact spaces needed to reach 60
    padding = " " * (INNER - len(content))
    # Using '+' ensures no hidden spaces are added by the print function
    print("|" + content + padding + "|")

def center_line(text):
    """Prints text perfectly centered within the borders."""
    content = text[:INNER]
    pad_total = INNER - len(content)
    pad_left = pad_total // 2
    pad_right = pad_total - pad_left
    print("|" + (" " * pad_left) + content + (" " * pad_right) + "|")

def two_col_line(left_part, right_part):
    """Calculates a gap to keep text on the left and right edges."""
    l_text = str(left_part).strip()
    r_text = str(right_part).strip()
    
    # Calculate gap size to ensure inner content is exactly 60
    # Equation: len(l_text) + gap + len(r_text) = 60
    gap_size = INNER - len(l_text) - len(r_text)
    
    # Safety check for very long names
    if gap_size < 1:
        gap_size = 1
        l_text = l_text[:INNER - len(r_text) - 1]

    # Combine: | (1) + Content (60) + | (1) = 62
    print("|" + l_text + (" " * gap_size) + r_text + "|")

# -------- Main Program Section --------

# Collecting all required details from the user
# .strip() removes accidental leading/trailing spaces that ruin alignment
school = input("Enter Name of School: ").strip()
name = input("Enter Student Name: ").strip()
roll = input("Enter Roll No: ").strip()
clas = input("Enter Class: ").strip()
section = input("Enter Section: ").strip()
addr1 = input("Enter Address Line 1: ").strip()
addr2 = input("Enter Address Line 2: ").strip()
city = input("Enter City: ").strip()
pin = input("Enter Pin Code: ").strip()
contact = input("Enter Parent's Contact No: ").strip()

# Display the formatted ID Card
print("\n--- GENERATING ID CARD ---\n")

border_line()
center_line(school)
empty_line()

# Note: Labels like 'Student Name:' and 'Roll No:' are part of the length
two_col_line("Student Name: " + name, "Roll No: " + roll)
two_col_line("Class: " + clas, "Section: " + section)

left_line("Address : " + addr1)
left_line("          " + addr2)

empty_line()
two_col_line("City: " + city, "Pin Code: " + pin)

left_line("Parent's Contact No: " + contact)
border_line()
Sample Output
If inputs are like the example (Vidyarthi, 999, XI, Z, etc.), the output will look like this:
Enter Name of School: XYZ School
Enter Student Name: Vidyarthi
Enter Roll No: 999
Enter Class: XI
Enter Section: Z
Enter Address Line 1: Mera Ghar 1
Enter Address Line 2: Mera Ghar 2
Enter City: Mera Shehar
Enter Pin Code: 999999
Enter Parent's Contact No: +91 9999999999

--- GENERATING ID CARD ---

+------------------------------------------------------------+
|                         XYZ School                         |
|                                                            |
|Student Name: Vidyarthi                         Roll No: 999|
|Class: XI                                         Section: Z|
|Address : Mera Ghar 1                                       |
|          Mera Ghar 2                                       |
|                                                            |
|City: Mera Shehar                           Pin Code: 999999|
|Parent's Contact No: +91 9999999999                         |
+------------------------------------------------------------+