Grade 11 - Computer Science With Python
Grade 11 - Computer Science With Python
Seal Principal
Date
[Link] NAME OF THE EXERCISE [Link] Remarks
14. 20/08/25
PROGRAM TO DEMONSTRATE THE STRING
MANIPULATION
16. 20/08/25
PROGRAM TO GENERATE A PATTERN
GENERATION
17. 03/09/25
PROGRAM TO GENERATE A PYRAMID
PATTERNS
18. 03/09/25
PROGRAM TO DISPLAY THE RESULTING
TOTAL TIME IN THE AM/PM FORMAT.
19. 07/09/25
PROGRAM TO CHECKS WHETHER THE TWO
STRINGS ARE ANAGRAMS
20. 07/09/25
PROGRAM TO DISPLAY SECOND LARGEST
ELEMENT FROM A LIST
21. 12/09/25
PROGRAM TO GENERATE A SERIES USING
LIST COMPREHENSION
22. 19/09/25
PROGRAM TO DEMONSTRATE THE LIST
MANIPULATION
23. 26/09/25
PROGRAM TO DISPLAY WEATHER
PATTERNS FOR THE MONTH
24. 10/10/25
PYTHON MODULE TO IMPLEMENT
FUNCTIONS
25. 17/10/25
PROGRAM TO PERFORM 2D POINTS
ANALYSIS USING TUPLES
26. 11/12/25
PROGRAM TO COUNT AND DISPLAYS THE
NUMBER OF OCCURRENCES OF VOWELS
PROGRAM TO COUNT AND DISPLAYS THE
27. 18/12/25 FREQUENCY OF APPEARANCE OF EACH
WORD IN THE STRING.
28. 06/01/26
PROGRAM TO DISPLAY THE NAME AND
HIGHEST TOTAL USING DICTIONARY
30. 20/01/26
PROGRAM TO DEMONSTRATE BUBBLE AND
INSERTION SORT
Python Program
PROGRAM – 1: DATE: 04/06/25
1. Write a program to swap two numbers (not menu driven) a. Using third variable b. Without using third
variable.
Source Code:
#1 Number swapping
print("###Number Swapping###")
print(" - using third variable\n")
num1=int(input("Enter a number:"))
num2=int(input("Enter another number:"))
print(f'The numbers before swap:- number1 is {num1} and number2 is {num2}')
num3=num1
num1=num2
num2=num3
print(f'The numbers after swap:- number1 is {num1} and number2 is {num2}')
print("\n")
print("###Number Swapping###")
print(" - without using third variable\n")
num1=int(input("Enter a number:"))
num2=int(input("Enter another number:"))
print(f'The numbers before swap:- number1 is {num1} and number2 is {num2}')
num1, num2=num2, num1
print(f'The numbers after swap:- number1 is {num1} and number2 is {num2}')
Output:
2. Write a program to arrange three user given numbers in ascending order.
Source Code:
Output:
3 .Write a menu driven program to a. Calculate the Simple interest – showcase user defined function
(no arguments, with return) b. Calculate the Compound interest – showcase user defined function
(no arguments, no return)
Sample Code:
def simple_interest():
p = float(input("Enter Principal amount: "))
r = float(input("Enter Rate of Interest: "))
t = float(input("Enter Time (in years): "))
si = (p * r * t) / 100
return si
def compound_interest():
p = float(input("Enter Principal amount: "))
r = float(input("Enter Rate of Interest: "))
t = float(input("Enter Time (in years): "))
ci = p * ((1 + r / 100) ** t) - p
print("Compound Interest = ", ci)
while True:
print("\n--- Interest Calculator Menu ---")
print("1. Simple Interest")
print("2. Compound Interest")
print("3. Exit")
choice = int(input("Enter your choice: "))
if choice == 1:
result = simple_interest()
print("Simple Interest = ", result)
elif choice == 2:
compound_interest()
elif choice == 3:
print("Exiting program... Goodbye!")
break
else:
print("Invalid choice! Please try again.")
Output:
Calculate the Simple interest
a. Calculate the Compound interest
[Link] a Python program that takes the coefficients a, b, and c of a quadratic equation as input,
calculates the discriminant, and based on the value of the discriminant:
If it is positive, computes and prints the two real and distinct roots
If it is zero, computes and prints the one real root
If it is negative, displays a message saying that the equation has no real roots
Source Code:
Output:
Case 2 (d = 0 – One root):
Source Code:
while True:
if choice == 1:
# Final velocity
U = float(input("Enter initial velocity (U): "))
a = float(input("Enter acceleration (a): "))
t = float(input("Enter time (t): "))
V=U+a*t
print("Final Velocity (V) =", V)
elif choice == 2:
# Displacement
U = float(input("Enter initial velocity (U): "))
a = float(input("Enter acceleration (a): "))
t = float(input("Enter time (t): "))
S = U * t + 0.5 * a * (t ** 2)
print("Displacement (S) =", S)
elif choice == 3:
# Final velocity squared
U = float(input("Enter initial velocity (U): "))
a = float(input("Enter acceleration (a): "))
S = float(input("Enter displacement (S): "))
V2 = (U ** 2) + 2 * a * S
print("Final Velocity Squared (V^2) =", V2)
elif choice == 4:
print("Exiting program... Goodbye!")
break
else:
print("Invalid choice! Please enter 1–4.")
Output:
1. Final Velocity:
2. Displacement:
Source Code:
# Simple Calculator
while True:
print("\n--- Simple Calculator ---")
print("1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n5. Exit")
choice = int(input("Enter your choice (1-5): "))
if choice in [1,2,3,4]:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if choice == 1: print("Result =", num1 + num2)
elif choice == 2: print("Result =", num1 - num2)
elif choice == 3: print("Result =", num1 * num2)
elif choice == 4:
print("Result =", num1 / num2 if num2 != 0 else "Error! Division by zero.")
elif choice == 5:
break
else: print("Invalid choice!")
Output:
7. Write a Python program to calculate the area of the following shapes:
a. Circle
b. Square
c. Rectangle
d. Triangle
The program should display a menu for the user to select which shape's area they want to calculate.
Based on the user’s selection, prompt for the required inputs (e.g., radius for circle, sides for square) and
display the calculated area. The program should continue in a loop until the user chooses to exit.
Source Code:
# Area Calculator
while True:
print("\n--- Area Calculator ---")
print("1. Circle\n2. Square\n3. Rectangle\n4. Triangle\n5. Exit")
choice = int(input("Enter your choice (1-5): "))
if choice == 1:
r = float(input("Enter radius: "))
print("Area =", 3.14159 * r**2)
elif choice == 2:
s = float(input("Enter side: "))
print("Area =", s**2)
elif choice == 3:
l = float(input("Enter length: "))
b = float(input("Enter breadth: "))
print("Area =", l * b)
elif choice == 4:
b = float(input("Enter base: "))
h = float(input("Enter height: "))
print("Area =", 0.5 * b * h)
elif choice == 5:
break
else: print("Invalid choice!")
Output:
8. Write a Python program to calculate the Greatest Common Divisor (GCD) and Least Common
Multiple (LCM) of two given numbers. The program should loop to allow the user to enter
different sets of numbers and calculate the GCD and LCM until they choose to exit.
Source Code:
# Calculate GCD
x, y = a, b
while y != 0:
x, y = y, x % y
gcd = x
# Calculate LCM
lcm = (a * b) // gcd
Source Code:
while True:
print("\n--- Menu ---")
print("1. Primes 1-100\n2. Fibonacci series\n3. Exit")
choice = int(input("Enter choice: "))
if choice == 1:
primes = [x for x in range(2,101) if all(x%i!=0 for i in range(2,int(x**0.5)+1))]
print(primes)
elif choice == 2:
n = int(input("Enter n terms: "))
print(fibonacci(n))
elif choice == 3:
break
else:
print("Invalid choice!")
10. Write a Python program with the following options:
a. Calculate the factorial of a given number.
b. Determine whether a given number is a Krishnamurthy number (a number whose
sum of the factorial of its digits equals the number itself).
The program should:
Use a function to calculate the factorial, which is called from both options
Display a menu for the user to select the desired operation
Continue the program in a loop until the user chooses to exit
Source Code:
while True:
print("\n1. Factorial\n2. Krishnamurthy\n3. Exit")
choice = int(input("Enter choice: "))
if choice == 1:
num = int(input("Enter number: "))
print("Factorial =", factorial(num))
elif choice == 2:
num = int(input("Enter number: "))
sum_fact = sum(factorial(int(d)) for d in str(num))
print("Krishnamurthy" if sum_fact==num else "Not a Krishnamurthy number")
elif choice == 3:
break
else: print("Invalid choice!")
Output:
11. Write a Python program with the following options:
a. Determine whether a given number is an Armstrong number.
b. Determine whether a given number is a Neon number (a number where the sum of
digits of the square of the number is equal to the number itself).
The program should display a menu for the user to choose the operation and continue until the
user chooses to exit.
Source Code:
while True:
print("\n1. Armstrong\n2. Neon\n3. Exit")
choice = int(input("Enter choice: "))
if choice == 1:
num = int(input("Enter number: "))
sum_pow = sum(int(d)**len(str(num)) for d in str(num))
print("Armstrong" if sum_pow==num else "Not Armstrong")
elif choice == 2:
num = int(input("Enter number: "))
square = num**2
sum_digits = sum(int(d) for d in str(square))
print("Neon" if sum_digits==num else "Not Neon")
elif choice == 3:
break
else: print("Invalid choice!")
Output:
12. Write a Python program to input a number and check whether it is a Perfect, Abundant, or
Deficient number:
A perfect number is one where the sum of its divisors equals the number itself.
An abundant number has a sum of divisors greater than the number.
A deficient number has a sum of divisors less than the number.
The program should continue in a loop until the user chooses to exit.
Source Code:
while True:
num = int(input("\nEnter number (0 to exit): "))
if num == 0: break
div_sum = sum(i for i in range(1,num) if num % i == 0)
if div_sum == num: print("Perfect")
elif div_sum > num: print("Abundant")
else: print("Deficient")
Output:
13. Write a Python program with the following options:
a. Check whether a given string is a palindrome.
b. Check whether a given number is a palindrome.
The program should display a menu for the user to choose between checking a string or a number.
Continue prompting the user in a loop until they choose to exit.
Source Code:
while True:
print("\n1. String Palindrome\n2. Number Palindrome\n3. Exit")
choice = int(input("Enter choice: "))
if choice == 1:
s = input("Enter string: ")
print("Palindrome" if s==s[::-1] else "Not Palindrome")
elif choice == 2:
n = input("Enter number: ")
print("Palindrome" if n==n[::-1] else "Not Palindrome")
elif choice == 3:
break
else: print("Invalid choice!")
Output:
14. Write a Python program to demonstrate the following string manipulation functionalities:
a. swapcase(): Convert all uppercase letters in a string to lowercase, and vice versa.
b. partition(): Input a conjunct sentence from the user and partition it based on one of the
following conjunctions: and, but, or, nor, so, for, yet.
c. join(): Demonstrate the usage of the join() method by combining a list of words into a single
sentence, with a space separating each word.
Example:
Input: ['Python', 'is', 'a', 'powerful', 'programming', 'language']
Output: "Python is a powerful programming language"
The program should display a menu for the user to choose which string manipulation they want to
perform and continue in a loop until the user chooses to exit.
Source Code:
while True:
print("\n1. Swapcase\n2. Partition\n3. Join\n4. Exit")
choice = int(input("Enter choice: "))
if choice == 1:
s = input("Enter string: ")
print([Link]())
elif choice == 2:
s = input("Enter sentence: ")
conj = ['and','but','or','nor','so','for','yet']
for c in conj:
if c in s:
print([Link](c))
break
elif choice == 3:
lst = input("Enter words separated by space: ").split()
print(" ".join(lst))
elif choice == 4:
break
else: print("Invalid choice!")
Output:
15. Case Study: User Sign-Up Validation
A website requires users to sign up with an email ID and password, following specific rules to
ensure the security and validity of user credentials. Write a Python program to validate the email
and password entered by the user based on the following criteria:
Email Validation Rules:
The email must contain exactly one "@" symbol.
The domain name (after "@") should be at least 3 characters long.
The email must end with a valid domain suffix such as .com, .org, .edu, or .net.
No spaces are allowed in the email.
Password Validation Rules:
The password must be at least 8 characters long.
It must contain at least:
One uppercase letter, One lowercase letter, One digit, One special character (from !
@#$%^&*()_+) and no space
Write a Python program that prompts the user to enter an email ID and password during sign-up and
validates the email ID based on the rules above and displays an appropriate message if the email is
invalid. Validates the password based on the rules above and displays an appropriate message if the
password is invalid. If both email and password are valid, display a message saying "Sign-up successful!"
Source Code:
email = input("Enter email: ")
password = input("Enter password: ")
if [Link]("@") != 1 or " " in email:
print("Invalid Email!")
elif len([Link]("@")[1].split(".")[0]) < 3 or not [Link]((".com",".org",".edu",".net")):
print("Invalid Email!")
# Password Validation
elif len(password) < 8:
print("Invalid Password! Too short.")
elif not any([Link]() for c in password):
print("Invalid Password! Must contain uppercase.")
elif not any([Link]() for c in password):
print("Invalid Password! Must contain lowercase.")
elif not any([Link]() for c in password):
print("Invalid Password! Must contain a digit.")
elif not any(c in "!@#$%^&*()_+" for c in password):
print("Invalid Password! Must contain special character.")
elif " " in password:
print("Invalid Password! No spaces allowed.")
else:
print("Sign-up successful!")
Output:
16. Write a menu driven program to generate the following number pattern:
Source Code:
while True:
print("menu")
if ch==1:
print("pattern 1")
n=5
for i in range(1,n+1):
x="A"
for j in range(1,i+1):
print(x, end="")
x=chr(ord(x)+1)
print()
elif ch==2:
print("pattern 2")
n=5
for i in range(n,0,-1):
ch=chr(65 +(n-i))
for j in range(i,0,-1):
print(ch,end="")
print()
elif ch==3:
print("pattern 3")
n=5
for i in range(1,n+1):
elif ch==4:
print("pattern 4")
n=5
print(j,end="")
print()
elif ch==5:
print("end of code")
break
else:
print("invalid number")
Output:
[Link] a menu driven program to generate the following pyramid patterns:
Source Code:
while True:
print("enter 1 for pattern 1")
print("enter 2 for pattern 2")
ch=int(input("enter the choice:"))
if ch==1:
print("pattern 1")
rows = 5
for i in range(rows):
print(" " * (rows - i - 1), end="")
for j in range(i + 1):
print("*", end=" ")
print()
elif ch==2:
print("pattern 2")
letter=["A","B","C", "D","E"]
counts=[8,7,6,3,1]
for i in range (len(letter)):
print(" "*i+letter[i]*counts[i])
Output:
18. Write a Python program that:
Reads two times from the user in the format hh:mm:ss.
Adds these two times together, ensuring proper conversion of seconds to minutes, minutes
to hours and hours to day, where necessary.
Displays the resulting total time in the AM/PM format.
Input:
Time 1: 12:45:30
Time 2: 02:20:45
Output:
Total Time: 03:06:15 PM
Source Code:
total_s = s1 + s2
extra_m, s = divmod(total_s, 60)
total_m = m1 + m2 + extra_m
extra_h, m = divmod(total_m, 60)
total_h = h1 + h2 + extra_h
total_h_12 = total_h % 12
total_h_12 = total_h_12 if total_h_12 != 0 else 12
am_pm = "AM" if (total_h % 24) < 12 else "PM"
Source Code:
while True:
s1 = input("String 1 (or 'exit' to quit): ")
if [Link]() == 'exit': break
s2 = input("String 2: ")
Source Code:
for n in nums:
if first is None or n > first:
second = first
first = n
elif n != first and (second is None or n > second):
second = n
if second is None:
print("No second largest element")
else:
print("Second largest element:", second)
Output:
21. Write a menu driven program using list comprehension to (menu driven with loop)
a. Generate a list of number series [x2, (x+1)2…. (x+n)2]
b. Generate a list of alphabet series [‘a’,’ab’,’abc’….] from the string
‘abcdefghijklmnopqrstuvwxyz’
c. Generate the nested list [[1, 4, 9], [16, 25, 36], [49, 64, 81], [100, 121, 144], [169, 196, 225]]
Source Code:
import string
while True:
print("\n1. Number Series\n2. Alphabet Series\n3. Nested List\n4. Exit")
choice = int(input("Choice: "))
if choice == 1:
x = int(input("Start number x: "))
n = int(input("Length n: "))
series = [(x+i)**2 for i in range(n)]
print(series)
elif choice == 2:
s = string.ascii_lowercase
series = [s[:i+1] for i in range(len(s))]
print(series)
elif choice == 3:
nested = [[(i+j)**2 for j in range(3)] for i in range(1, 22, 3)]
print(nested)
elif choice == 4:
break
Output:
22. Write a Python program to demonstrate the following list manipulation operations:
a. Insertion: Add an element at a specific position in the list.
b. Deletion: Remove an element from the list by value or by index.
c. Linear Search: Search for an element in the list and display its index if found.
The program should:
Display a menu for the user to choose which operation they want to perform.
Perform the selected operation and display the updated list after each action.
The program should continue to prompt the user in a loop until they choose to exit.
Source Code:
lst = []
while True:
print("\n1. Insert\n2. Delete\n3. Linear Search\n4. Display List\n5. Exit")
choice = int(input("Choice: "))
if choice == 1:
val = int(input("Value to insert: "))
pos = int(input("Position (0-indexed): "))
[Link](pos, val)
elif choice == 2:
val = int(input("Value to remove: "))
if val in lst: [Link](val)
else: print("Value not in list")
elif choice == 3:
val = int(input("Value to search: "))
if val in lst: print("Index:", [Link](val))
else: print("Not found")
elif choice == 4:
print(lst)
elif choice == 5:
break
Output:
23. Case Study: Weather Analysis
A meteorological department collects daily temperature data (in degrees Celsius) for 30 days and
stores it in a list. The goal is to analyse the data and draw conclusions about the weather patterns
for the month.
temperatures = [29, 31, 30, 28, 32, 33, 27, 26, 25, 30, 28, 29, 31, 30, 26, 25, 27, 28, 29, 32, 33, 30, 28,
31, 29, 30, 27, 28, 30, 29]
Write a menu driven program to:
1. Calculate the Average Temperature
2. Display the count of Hot Days when the temperature exceeds 30°C
3. Find the Maximum and Minimum Temperature
4. To categorize the days into three temperature ranges: Less than 28°C Between 28°C and
30°C Greater than 30°C 5. Displays any streak of consecutive hot days
Source Code:
temps = [29,31,30,28,32,33,27,26,25,30,28,29,31,30,26,25,27,28,29,32,33,30,28,31,29,30,27,28,30,29]
while True:
print("\n1. Average Temp\n2. Hot Days (>30)\n3. Max & Min Temp\n4. Categorize Days\n5. Hot
Streaks\n6. Exit")
choice = int(input("Choice: "))
if choice == 1:
print("Average Temp:", sum(temps)/len(temps))
elif choice == 2:
print("Hot Days:", len([t for t in temps if t>30]))
elif choice == 3:
print("Max:", max(temps), "Min:", min(temps))
elif choice == 4:
print("Less than 28:", [t for t in temps if t<28])
print("28-30:", [t for t in temps if 28<=t<=30])
print("Greater than 30:", [t for t in temps if t>30])
elif choice == 5:
streak=0; max_streak=0
for t in temps:
if t>30: streak+=1
else: streak=0
max_streak=max(max_streak,streak)
print("Longest hot streak:", max_streak, "days")
elif choice == 6:
break
Output:
24. Write a Python module to implement functions for converting distances between different units
(e.g., kilometers to miles, meters to feet, and vice versa). The module should provide a user-
friendly interface to input the distance and the desired unit conversions. The module functions
should take arguments and return the value.
Source Code:
# distance_module.py
def km_to_miles(km):
return km * 0.621371
def miles_to_km(miles):
return miles / 0.621371
def m_to_feet(m):
return m * 3.28084
def feet_to_m(m):
return m / 3.28084
while True:
print("\n1. km to miles\n2. miles to km\n3. meters to feet\n4. feet to meters\n5. Exit")
choice = int(input("Choice: "))
if choice==1: print("Miles:", km_to_miles(float(input("Enter km: "))))
elif choice==2: print("Km:", miles_to_km(float(input("Enter miles: "))))
elif choice==3: print("Feet:", m_to_feet(float(input("Enter meters: "))))
elif choice==4: print("Meters:", feet_to_m(float(input("Enter feet: "))))
elif choice==5: break
Output:
25. Case Study – 2D Points Analysis
A 2D coordinate system stores multiple points as tuples of (x, y) coordinates. The points are
represented as coordinates = [(1, 2), (3, 4), (-1, -3), (0, 0)] Write a menu-driven program to:
1. Calculate the distance of each point from the origin (0, 0)
2. Identify the point farthest from the origin
3. Add a new point to the list while maintaining the tuple structure
4. Display all points within a range for x and y coordinates
5. Check if any point lies on either the x-axis or y-axis.
Source Code:
import math
points = [(1,2),(3,4),(-1,-3),(0,0)]
while True:
print("\[Link] from origin\[Link] point\[Link] point\[Link] in range\[Link] on axes\
[Link]")
choice = int(input("Choice: "))
if choice==1:
for p in points:
print(p, "Distance:", round([Link](p[0],p[1]),2))
elif choice==2:
farthest = max(points, key=lambda p: p[0]**2 + p[1]**2)
print("Farthest point:", farthest)
elif choice==3:
x=int(input("x: ")); y=int(input("y: "))
[Link]((x,y))
print("Added:", (x,y))
elif choice==4:
x1=int(input("x min: ")); x2=int(input("x max: "))
y1=int(input("y min: ")); y2=int(input("y max: "))
filtered=[p for p in points if x1<=p[0]<=x2 and y1<=p[1]<=y2]
print("Points in range:", filtered)
elif choice==5:
axes=[p for p in points if p[0]==0 or p[1]==0]
print("Points on axes:", axes)
elif choice==6:
break
Output:
Source Code:
vowels = "aeiouAEIOU"
while True:
s = input("Enter sentence (or 'exit'): ")
if [Link]() == 'exit': break
for word in [Link]():
count = sum(1 for c in word if c in vowels)
print(f"{word}: {count}")
Output:
27. Write a Python program that:
Takes a long string as input from the user.
Counts and displays the frequency of appearance of each word in the string.
Source Code:
while True:
s = input("Enter string (or 'exit'): ")
if [Link]()=='exit': break
freq={}
for word in [Link]():
freq[word] = [Link](word,0)+1
for k,v in [Link](): print(f"{k}: {v}")
Output:
28. Write a Python program that:
a. Takes the names and marks in 5 subjects for n students.
b. Stores the information in a dictionary where the key is the student’s name and the value is
their marks.
c. Calculates and displays the total marks for each student.
d. Displays the name and total marks of the student with the highest total (the topper).
The program should continue allowing input for multiple batches of students until the user
chooses to exit.
Example:
Input:
Student 1: Name: "John", Marks: [85, 90, 78, 92, 88]
Student 2: Name: "Jane", Marks: [88, 79, 85, 91, 95]
Output:
John: 433
Jane: 438
Topper: Jane with 438 marks
Source Code:
while True:
n = int(input("Number of students (0 to exit): "))
if n==0: break
students={}
for _ in range(n):
name = input("Student name: ")
marks = list(map(int,input("5 marks separated by space: ").split()))
students[name]=sum(marks)
for name,total in [Link](): print(f"{name}: {total}")
topper=max(students,key=[Link])
print(f"Topper: {topper} with {students[topper]} marks")
Output:
29. Write a Python program that performs the following conversions:
a. Binary to Decimal conversion.
b. Decimal to Binary conversion.
The program should:
Display a menu for the user to choose which conversion they want to perform.
Prompt the user for the appropriate input and display the result.
Continue prompting the user in a loop until they choose to exit.
Source Code:
while True:
print("\[Link] to Decimal\[Link] to Binary\[Link]")
choice=int(input("Choice: "))
if choice==1:
b=input("Enter binary: ")
print("Decimal:", int(b,2))
elif choice==2:
d=int(input("Enter decimal: "))
print("Binary:", bin(d)[2:])
elif choice==3:
break
Output:
30. Write a Python program that demonstrates the following sorting algorithms on a list of integers:
a. Bubble Sort
b. Insertion Sort
The program should:
Display a menu for the user to choose which sorting method to apply.
Prompt the user to enter a list of integers and display the sorted list after performing the
chosen sort.
Continue prompting the user in a loop until they choose to exit.
#30 Bubble sort and Insertion sort
Source Code:
while True:
print("\[Link] Sort\[Link] Sort\[Link]")
choice=int(input("Choice: "))
if choice in [1,2]:
lst=list(map(int,input("Enter numbers: ").split()))
if choice==1:
# Bubble Sort
for i in range(len(lst)):
for j in range(0,len(lst)-i-1):
if lst[j]>lst[j+1]: lst[j],lst[j+1]=lst[j+1],lst[j]
else:
# Insertion Sort
for i in range(1,len(lst)):
key=lst[i]; j=i-1
while j>=0 and lst[j]>key:
lst[j+1]=lst[j]; j-=1
lst[j+1]=key
print("Sorted list:", lst)
elif choice==3:
break
Output: