0% found this document useful (0 votes)
23 views

Practical File Ques Class XII 2024-25

Uploaded by

fhquwron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Practical File Ques Class XII 2024-25

Uploaded by

fhquwron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

PRACTICAL FILE QUESTIONS

Q 1. Write a program to show that the entered string is a palindrome or not


Q 2. Write a program to show the count of characters in the given line(to count the number of
alphabets, digits, uppercase, lowercase, spaces and other characters)
Q 3. Write a program to remove all odd numbers from the given list
Q 4. Write a program to display those strings which are starting with ‘A’ from the given list.
Q 5. Write a program to display frequencies(how many times the element will occur) of all the
elements of a list.
Q 6. Write a program to find and display the sum of all the values which are ending with 3, from a list
Q 7. Write a program to input names of ‘n’ countries and their capitals and currency. Store it in a
dictionary and display in tabular form . Also search and display for a particular country.
Q 8. Write a program to show elements of two dimensional list in a 2-D array format
Q 9. Write a program to find the factorial of an entered number using function fact()
Q 10. Write SQL Queries and find outputs for SQL queries which based on given tables
Q 11. Write a program that interactively creates a nested tuple to store the marks in three subjects
for five students, i.e., tuple will look somewhat like:

((45,45,40),(35,40,38),(36,30,38),(25,27,20),(10,15,20))
Also add a function that computes total marks and average marks obtained by each student.

Q 12. Write a Python function SORT to sort (ascending and descending) a dictionary by value.

Sample Output
dictionary = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
Ascending order = [ (0, 0), (2, 1), (1, 2), (4, 3), (3, 4) ]
Descending order = {3: 4, 4: 3, 1: 2, 2: 1, 0: 0}

Q 13. Write a function AMCount() in Python, which should read each character of a text file
STORY.TXT,
should count and display the occurance of alphabets 'A' and 'M' (including small cases 'a' and
'm 'too).

Example: If the file content is as follows:


Updated information as simplified by official websites.
The AMCount() function should display the output as: A or a = 4, M or m

Q 14. A binary file "STUDENT.DAT" has structure [admission_number, Name, Percentage].


Write a function countrec() in Python that would read contents of the file "STUDENT.DAT" and
display the details of those students whose percentage is above 75.
Also display number of students scoring above 75%.

Q 15. Write a program to take two numbers as input and display any random number between those
two numbers.
import random

def random_between(a, b):


return random.randint(a, b)

num1 = int(input("Enter the first number: "))


num2 = int(input("Enter the second number: "))

print(random_between(num1, num2))

Q 16. Write a program to take a number and display its square root using function of math module.

import math

def square_root(num):
return math.sqrt(num)
number = float(input("Enter a number: "))
print(square_root(number))

Q 17. Write a program to take a floating point number with 5 decimal digits as input and display
after rounding of that value to 2 decimal places using function of math module

import math
n=float(input("Enter number with 5 decimal digits:"))
r=round(n,2)
print("Output:",r)

Q 18. Write a program to create a Stack for storing only odd numbers out of all the numbers entered
by the user.
Display the content of the Stack along with the largest odd number in the Stack. (Hint. Keep popping
out the elements from stack and maintain the largest element retrieved so far in a variable. Repeat
till Stack is empty).

put("Enter no of elements:"))
for i in r l=[]
n=int(in ange(0,n):
k=int(input("Enter element of list:"))
if k%2!=0:
l.append(k)
print(l)

max=l[0]
for i in range(1,len(l)):
if max<l[i]:
max=l[i]
print("Largest number:",max)

Q 19. A list contains the following record of a Hostel:


[Hostel_No, Total_Students, Total_Rooms]
Write the following user defined functions to perform given operations on the stack named “Hostel”:
i. Push_element()- To push an object containing Hostel_No and Total_Students along with
Total_Rooms to the stack
ii. Pop_element()- To pop the objects from the stack and display them. Also display “Stack
Empty” when there are no elements in the stack.

Q 20. Write a code to establish connectivity between python and MySQL to create a new database
‘SALES’ and a new table ‘SALESPERSON’.

import mysql.connector

def create_database():
conn = mysql.connector.connect(host='localhost', user='username', password='password')
cursor = conn.cursor()
cursor.execute("CREATE DATABASE")
cursor.close()
conn.close()

create_database()
print("Database created successfully.")

Q 21. Write a code to establish connectivity between python and MySQL to insert data into the
table ‘SALESPERSON’. Also display the data of the table.
import mysql.connector
conn = mysql.connector.connect( host="localhost", user="username", password="password",
database="database")
cursor = conn.cursor()
cursor.execute("INSERT INTO SALESPERSON (name, sales_amount) VALUES ('BOB', 500)""")
cursor.execute("SELECT * FROM SALESPERSON")
rows = cursor.fetchall()
for row in rows:
on print(row)
cursor.close()
cn.close()

Q 22. Create a table employee insert records in it and perform the following operations:
i. Write a query to display details of all employees
ii. Write a query to display average salary of employees of department accounts
iii. Write a query to display sum of salary of all employees
iv. Write a query to add a column office_site with varchar and size 60 in employee table
v. Write query to display all details of employees whose first name starts with D
vi. Display details of all employees in order of their salary
vii. Display average salary of employee under manager ‘Wardman’
viii. Write a query to delete a column manager from table employee
ix. Update salary of employee E345 to 35,000
x. Delete data of ‘Mohan’ from table employee
xi. Write a query to count employees department Wise
xii. Write a query to show employee details do not have any manager
i. select * from employees;
ii.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy