INDIAN SCHOOL DARSAIT
MODEL PRACTICAL EXAMINATION, JANUARY 2025
INFORMATICS PRACTICES (065)
Class: XI Max. Marks: 30
General Instructions:
• All the questions are compulsory.
1. Write a menu driven program in Python to perform the following as per user’s choice:
i) To check whether the given number is palindrome or not.
ii) To count the frequency of an element in each list of numbers.
iii) To exit
Display proper message for an invalid choice. The program should continue until the user
wants to exit.
# Create an infinite loop for the menu
while True:
# Display the menu to the user
print("\nMenu:")
print("1. Check if a number is palindrome")
print("2. Count frequency of an element in a list")
print("3. Exit")
# Ask the user for their choice
choice = input("Enter your choice: ")
if choice == '1':
# Prompt user to enter a number
number = input("Enter the number: ")
# Check if the number is a palindrome by comparing it with its reverse
if number == number[::-1]:
print(number + " is a palindrome.") # Output if the number is a palindrome
else:
print(number + " is not a palindrome.") # Output if the number is not a palindrome
elif choice == '2':
# Prompt user to enter a list of numbers
numbers = input("Enter the list of numbers separated by space: ").split()
# Prompt user to enter the element whose frequency is to be counted
element = input("Enter the element to count: ")
Page 1 of 12
# Count the frequency of the element in the list
count = numbers.count(element)
print("The frequency of " + element + " is " + str(count) + ".") # Output the frequency
elif choice == '3':
# Exit the program
print("Exiting the program.")
break # Exit the loop
else:
# Handle invalid choices
print("Invalid choice. Please try again.")
2. Write a menu driven program in Python to perform the following as per user’s choice:
i) To find the sum and average of list of numbers accepted from the user.
ii) To print the given pattern
iii) To exit
Display proper message for an invalid choice. The program should continue until the user
wants to exit.
# Create an infinite loop for the menu
while True:
# Display the menu to the user
print("\nMenu:")
print("1. Find the sum and average of a list of numbers")
print("2. Print a pattern")
print("3. Exit")
# Ask the user for their choice
choice = input("Enter your choice: ")
if choice == '1':
# Prompt user to enter a list of numbers
numbers = list(map(float, input("Enter numbers separated by space: ").split()))
# Calculate the sum and average of the list
total = sum(numbers)
average = total / len(numbers) if numbers else 0
# Display the results
Page 2 of 12
print("Sum of numbers: " + str(total))
print("Average of numbers: " + str(average))
elif choice == '2':
# Prompt user to enter the number of rows for the pattern
rows = int(input("Enter the number of rows for the pattern: "))
# Print the pattern
print("The pattern is:")
for i in range(1, rows + 1):
print("* " * i)
elif choice == '3':
# Exit the program
print("Exiting the program.")
break # Exit the loop
else:
# Handle invalid choices
print("Invalid choice. Please try again.")
3. Write a menu driven program in Python to perform the following as per user’s choice:
i) To search for an element in each list along with its index.
ii) To check a 3-digit number is Armstrong number or not.
iii) To exit
Display proper message for an invalid choice. The program should continue until the user
wants to exit.
# Create an infinite loop for the menu
while True:
# Display the menu to the user
print("\nMenu:")
print("1. Search for an element in a list and display its index")
print("2. Check if a 3-digit number is an Armstrong number")
print("3. Exit")
# Ask the user for their choice
choice = input("Enter your choice: ")
if choice == '1':
# Prompt user to enter a list of numbers
numbers = input("Enter a list of numbers separated by space: ").split()
# Prompt user to enter the element to search for
element = input("Enter the element to search: ")
Page 3 of 12
# Check if the element is in the list and display its index
if element in numbers:
index = numbers.index(element)
print("Element " + element + " found at index " + str(index) + ".")
else:
print("Element " + element + " not found in the list.")
elif choice == '2':
# Prompt user to enter a 3-digit number
number = input("Enter a 3-digit number: ")
# Check if the input is a valid 3-digit number
if number.isdigit() and 100 <= int(number) <= 999:
# Calculate the sum of cubes of its digits
total = sum(int(digit)**3 for digit in number)
# Check if the number is an Armstrong number
if int(number) == total:
print(number + " is an Armstrong number.")
else:
print(number + " is not an Armstrong number.")
else:
print("Invalid input. Please enter a 3-digit number.")
elif choice == '3':
# Exit the program
print("Exiting the program.")
break # Exit the loop
else:
# Handle invalid choices
print("Invalid choice. Please try again.")
4. Write a menu driven program in Python to perform the following as per user’s choice:
i) To print the first 20 numbers in a Fibonacci series.
ii) To print the sum of even and odd numbers separately in a given list of numbers.
iii) To exit
Display proper message for an invalid choice. The program should continue until the user
wants to exit.
# Create an infinite loop for the menu
while True:
# Display the menu to the user
print("\nMenu:")
Page 4 of 12
print("1. Print the first 20 numbers in the Fibonacci series")
print("2. Print the sum of even and odd numbers in each list")
print("3. Exit")
# Ask the user for their choice
choice = input("Enter your choice: ")
if choice == '1':
# Generate the first 20 numbers in the Fibonacci series
fib_series = [0, 1] # Initialize the series with the first two numbers
while len(fib_series) < 20:
fib_series.append(fib_series[-1] + fib_series[-2]) # Append the next number
print("The first 20 numbers in the Fibonacci series are:")
print(fib_series)
elif choice == '2':
# Prompt the user to enter a list of numbers
numbers = list(map(int, input("Enter a list of numbers separated by space: ").split()))
# Calculate the sum of even and odd numbers
even_sum = sum(num for num in numbers if num % 2 == 0)
odd_sum = sum(num for num in numbers if num % 2 != 0)
# Display the results
print("Sum of even numbers: " + str(even_sum))
print("Sum of odd numbers: " + str(odd_sum))
elif choice == '3':
# Exit the program
print("Exiting the program.")
break # Exit the loop
else:
# Handle invalid choices
print("Invalid choice. Please try again.")
Page 5 of 12
5. Create the given table, insert the records and write the SQL commands for the following:
i) To display names of those garments that are available in ‘XL’ size.
ii) To display codes and names of those garments that have their names starting with ‘Ladies’.
iii) To display garment names, codes and prices of those garments that have prices in the range
1000.00 to 1500.00 (both 1000.00 and 1500.00 included).
iv) To change the colour of garment with code as 116 to “Orange”.
v) To display the garments in the descending order of their price.
1. Create the Table
CREATE TABLE GARMENT (
GCODE INT PRIMARY KEY,
GNAME VARCHAR(50),
SIZE CHAR(2),
COLOUR VARCHAR(20),
PRICE DECIMAL(10, 2)
);
2. Insert the Records
INSERT INTO GARMENT VALUES
(111, 'TShirt', 'XL', 'Red', 1400.00),
(112, 'Jeans', 'L', 'Blue', 1600.00),
(113, 'Skirt', 'M', 'Black', 1100.00),
(114, 'Ladies Jacket', 'XL', 'Blue', 4000.00),
(115, 'Trousers', 'L', 'Brown', 1500.00),
Page 6 of 12
(116, 'Ladies Top', 'L', 'Pink', 1200.00);
3. Queries
i) Display names of those garments that are available in ‘XL’ size.
SELECT GNAME FROM GARMENT WHERE SIZE = 'XL';
ii) Display codes and names of those garments that have their names starting with ‘Ladies’.
SELECT GCODE, GNAME FROM GARMENT WHERE GNAME LIKE 'Ladies%';
iii) Display garment names, codes, and prices of those garments that have prices in the range
1000.00 to 1500.00 (both included).
SELECT GNAME, GCODE, PRICE FROM GARMENT WHERE PRICE BETWEEN 1000.00 AND
1500.00;
iv) Change the colour of the garment with code 116 to “Orange”.
UPDATE GARMENT SET COLOUR = 'Orange' WHERE GCODE = 116;
v) Display the garments in the descending order of their price.
SELECT * FROM GARMENT ORDER BY PRICE DESC;
6. Create the given table, insert the records and write the SQL commands for the following:
i) To display name, location, city, SalesAmount of stores in descending order of SalesAmount.
ii) To display names of stores along with SalesAmount of those stores that have ‘fashion’
anywhere in their store names.
iii) To display Stores names, Location and Date Opened of stores that were opened before 1st
March 2015.
iv) To display the details of stores whose SaleAmount is between 300000 and 400000.
Page 7 of 12
v) To add a new column Stock of integer data type.
1. Create the Table
CREATE TABLE Store (
StoreId CHAR(4) PRIMARY KEY,
Name VARCHAR(50),
Location VARCHAR(50),
City VARCHAR(20),
NoOfEmployees INT,
DateOpened DATE,
SalesAmount DECIMAL(10, 2)
);
2. Insert the Records
INSERT INTO Store VALUES
('S101', 'Planetfashion', 'KarolBagh', 'Delhi', 7, '2015-10-16', 300000),
('S102', 'Trends', 'Nehru Nagar', 'Mumbai', 11, '2015-08-09', 400000),
('S103', 'Vogue', 'Vikas Vihar', 'Delhi', 10, '2015-06-27', 200000),
('S104', 'Superfashion', 'Defence Colony', 'Delhi', 8, '2015-02-18', 450000),
('S105', 'Rage', 'Bandra', 'Mumbai', 5, '2015-09-22', 600000);
3. Queries
i) To display name, location, city, SalesAmount of stores in descending order of SalesAmount.
SELECT Name, Location, City, SalesAmount FROM Store ORDER BY SalesAmount DESC;
ii) To display names of stores along with SalesAmount of those stores that have ‘fashion’
anywhere in their store names.
SELECT Name, SalesAmount FROM Store WHERE Name LIKE '%fashion%';
iii) To display Store names, Location, and Date Opened of stores that were opened before 1st
March 2015.
SELECT Name, Location, DateOpened FROM Store WHERE DateOpened < '2015-03-01';
iv) To display the details of stores whose SalesAmount is between 300000 and 400000.
SELECT * FROM Store WHERE SalesAmount BETWEEN 300000 AND 400000;
Page 8 of 12
v) To add a new column Stock of integer data type.
ALTER TABLE Store ADD Stock INT;
7. Create the given table, insert the records and write the SQL commands for the following:
i) To display names and drink codes of those drinks that have more than 120 calories.
ii) To display drink codes, names and calories of all drinks, in descending order of calories.
iii) To display names and price of drinks that have prices in the range 12 to 18 (both 12 and 18
included).
iv) Increase the price of all drinks in the given table by 10%.
v) To delete those records whose drinkcode is 105.
1. Create the Table
CREATE TABLE SOFTDRINK (
DRINKCODE INT PRIMARY KEY,
DNAME VARCHAR(50),
PRICE DECIMAL(5, 2),
CALORIES INT
);
2. Insert the Records
INSERT INTO SOFTDRINK VALUES
(101, 'Lime and Lemon', 20.00, 120),
(102, 'Apple Drink', 18.00, 120),
(103, 'Nature Nectar', 15.00, 115),
Page 9 of 12
(104, 'Green Mango', 15.00, 140),
(105, 'Aam Panna', 20.00, 135),
(106, 'Mango Juice Bahaar', 12.00, 150);
3. Queries
i) To display names and drink codes of those drinks that have more than 120 calories.
SELECT DNAME, DRINKCODE FROM SOFTDRINK WHERE CALORIES > 120;
ii) To display drink codes, names, and calories of all drinks, in descending order of calories.
SELECT DRINKCODE, DNAME, CALORIES FROM SOFTDRINK ORDER BY CALORIES
DESC;
iii) To display names and prices of drinks that have prices in the range 12 to 18 (both 12 and 18
included).
SELECT DNAME, PRICE FROM SOFTDRINK WHERE PRICE BETWEEN 12 AND 18;
iv) To increase the price of all drinks in the given table by 10%.
UPDATE SOFTDRINK SET PRICE = PRICE * 1.10;
v) To delete those records whose drinkcode is 105.
DELETE FROM SOFTDRINK WHERE DRINKCODE = 105;
Page 10 of 12
8. Create the given table, insert the records and write the SQL commands for the following:
i). To display Eno, Name, Gender from the table EMPLOYEE in ascending order of Eno.
ii). To display the Name of all the MALE employees from the table EMPLOYEE.
iii). To display the Eno and Name of those employees from the table EMPLOYEE who are born
between ‘1987-01-01’ and ‘1991-12-01’.
iv). To display FEMALE employees who have joined after ‘1986-01-01’.
v). To display all the details of employees whose name contains letter ‘L’;
vi). SELECT * FROM EMPLOYEE WHERE NAME LIKE ‘%L%’;
1. Create the Table
CREATE TABLE EMPLOYEE (
ENO INT PRIMARY KEY,
NAME VARCHAR(50),
DOJ DATE,
DOB DATE,
GENDER VARCHAR(10)
);
2. Insert the Records
INSERT INTO EMPLOYEE VALUES
(1001, 'George K', '2013-09-02', '1991-09-01', 'MALE'),
(1002, 'Ryma Sen', '2012-12-11', '1990-12-15', 'FEMALE'),
(1003, 'Mohitesh', '2013-02-03', '1987-09-04', 'MALE'),
Page 11 of 12
(1007, 'Anil Jha', '2014-01-17', '1984-10-19', 'MALE'),
(1004, 'Manila Sahai', '2012-12-09', '1986-11-14', 'FEMALE'),
(1005, 'R SAHAY', '2013-11-18', '1987-03-31', 'MALE'),
(1006, 'Jaya Priya', '2014-06-09', '1985-06-23', 'FEMALE');
3. Queries
i) Display Eno, Name, Gender in ascending order of Eno:
SELECT ENO, NAME, GENDER FROM EMPLOYEE ORDER BY ENO ASC;
ii) Display Name of all MALE employees:
SELECT NAME FROM EMPLOYEE WHERE GENDER = 'MALE';
iii) Display Eno and Name of employees born between '1987-01-01' and '1991-12-01':
SELECT ENO, NAME FROM EMPLOYEE WHERE DOB BETWEEN '1987-01-01' AND '1991-12-
01';
iv) Display FEMALE employees who joined after '1986-01-01':
SELECT * FROM EMPLOYEE WHERE GENDER = 'FEMALE' AND DOJ > '1986-01-01';
v) Display all details of employees whose name contains letter 'L':
SELECT * FROM EMPLOYEE WHERE NAME LIKE '%L%';
vi) The last query is already provided and is correct:
SELECT * FROM EMPLOYEE WHERE NAME LIKE '%L%';
Page 12 of 12