0% found this document useful (0 votes)
4 views8 pages

Practical File

Uploaded by

daiviksharma10b
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)
4 views8 pages

Practical File

Uploaded by

daiviksharma10b
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/ 8

Practical File

Computer Science (083)


2023-24

Submitted By
Name: DAIVIK SHARMA
Roll Number: 12
Class & Section: 11th-D

Rosary Senior Secondary School


Radio Colony, Kingsway Camp
Delhi – 110009
INDEX
S.n Name Of Practicals Page No. Signature
o
1. 3
WAP to find the largest element from a list (Elements of the list
should be taken from the user) without using built-in function.

2. 3
WAP to calculate mean of numeric values stored in a list.

3. 4
WAP to implement Linear Search on a list of numbers.

4. 4
WAP to count the frequency of an element in a list.

5. 5
WAP to input a list of numbers and swap elements at the even
location with the elements at the odd location.
6. 5
WAP to find the minimum (smallest) element from a tuple
(Elements of the tuple should be taken from the user) without using
built-in function.
7. 5
WAP to input any two tuples and swap their values and print these
two tuples.
8. 6
Create a dictionary with the roll number, name and marks of n
students in a class and display the names of students who have scored
marks above 75.
9. 6
WAP to count the number of times a character appears in a
given string using dictionary.

10. 7
WAP to input details of n employees (empname, salary-
basic,hra) and calculate total salary of each employee and display.

11. 7
WAP to display square root of a number using
math module.

12. 8
WAP to select a random subject from a list of
subjects.
Practical No. 1
Written By:DAIVIK SHARMA
WAP to find the largest element from a list (Elements of the list should be taken from
the user) without using built-in function.

Source Code:

user_input = input("Enter elements separated by spaces: ")


user_list = [int(x) for x in user_input.split()]

largest_element = user_list[0]
for element in user_list:
if element > largest_element:
largest_element = element

print("Largest Element:", largest_element)

Practical No.2

Written By: DAIVIK SHARMA


WAP to calculate mean of numeric values stored in a list.

Source Code:

from statistics import mean


l1 = []
n = int(input("Please Enter the No. of elements in the list"))
i=0

for i in range(n):
k = int(input("Enter the element"))
l1.append(k)

a = mean(l1)
print("Mean of The List is:",a)

Practical No.3

Written By: DAIVIK SHARMA

WAP to implement Linear Search on a list of numbers.


user_input = input("Enter elements separated by spaces: ")
user_list = [int(x) for x in user_input.split()]

search_number = int(input("Enter the number to search: "))

found = False
for i in range(len(user_list)):
if user_list[i] == search_number:
print(f"Number {search_number} found at index {i}.")
found = True
break

if not found:
print(f"Number {search_number} not found in the list.")

Practical No.4

Written By: DAIVIK SHARMA

WAP to count the frequency of an element in a list.

a = int(input("Enter No. of Elements"))


i=0
l = []

for i in range(a):
n = input("Enter the Element")
l.append(n)
print(l)

k = input("Enter the Element whose Frequency is To be Obtained")


if k in l:
count = l.count(k)
print("Frequency of" ,k,":", count)
if k not in l:
print("Required Element is Not Found")

Practical No.5

Written By: DAIVIK SHARMA

WAP to input a list of numbers and swap elements at the even location with the
elements at the odd location.
user_input = input("Enter elements separated by spaces: ")
user_list = [int(x) for x in user_input.split()]

for i in range(0, len(user_list)-1, 2):


user_list[i], user_list[i+1] = user_list[i+1], user_list[i]

print("Swapped List:", user_list)

Practical No.6

Written By: DAIVIK SHARMA

WAP to find the minimum (smallest) element from a tuple (Elements of the tuple should
be taken from the user) without using built-in function.

user_input = input("Enter elements separated by spaces: ")


user_tuple = tuple(str(x) for x in user_input.split())

min_element = user_tuple[0]
for element in user_tuple:
if element < min_element:
min_element = element

print("Minimum Element:", min_element)

Practical No.7

Written By: DAIVIK SHARMA


WAP to input any two tuples and swap their values and print these two tuples.

tuple1_input = input("Enter elements for the first tuple separated by spaces: ")
tuple1 = tuple(tuple1_input.split())

tuple2_input = input("Enter elements for the second tuple separated by spaces: ")
tuple2 = tuple(tuple2_input.split())

tuple1, tuple2 = tuple2, tuple1

print("\nModified Tuples:")
print("Tuple 1:", tuple1)
print("Tuple 2:", tuple2)

Practical No.8

Written By: DAIVIK SHARMA

Create a dictionary with the roll number, name and marks of n students in a class and
display the names of students who have scored marks above 75.

n = int(input("Enter the number of students: "))

students_dict = {}

for i in range(1, n + 1):


print(f"\nEnter details for Student {i}:")
roll_number = int(input("Roll Number: "))
name = input("Name: ")
marks = float(input("Marks: "))

students_dict[roll_number] = {'Name': name, 'Marks': marks}

print("\nNames of Students who scored more than 75:")


for roll_number, details in students_dict.items():
if details['Marks'] >= 75:
print(details['Name'])

Practical No.9

Written By: DAIVIK SHARMA


WAP to count the number of times a character appears in a given string using
dictionary.

user_input = input("Enter a string: ")

char_counts = {}

for char in user_input:


if char in char_counts:
char_counts[char] += 1
else:

char_counts[char] = 1
print("Character Counts:")
for char, count in char_counts.items():
print(f"'{char}': {count} times")

Practical No.10

Written By: DAIVIK SHARMA

WAP to input details of n employees (empname, salary-basic,hra) and calculate total


salary of each employee and display.

n = int(input("Enter the number of employees: "))


employee_details_list = []
for i in range(1, n + 1):
print(f"\nEnter details for Employee {i}:")
name = input("Name: ")
basic_salary = float(input("Basic Salary: "))
hra = float(input("HRA: "))

total_salary = basic_salary + hra

employee_details = {'Name': name, 'Basic Salary': basic_salary, 'HRA': hra, 'Total Salary': total_salary}

employee_details_list.append(employee_details)

print("\nEmployee Details and Total Salary:")


for employee in employee_details_list:
print(f"\nName: {employee['Name']}")
print(f"Basic Salary: {employee['Basic Salary']}")
print(f"HRA: {employee['HRA']}")
print(f"Total Salary: {employee['Total Salary']}")

Practical No.11

Written By: DAIVIK SHARMA

WAP to display square root of a number using math module.

SSfrom math import sqrt


n = int(input("Enter the Number"))
s = sqrt(n)
print("The Square Root for",n,"is:",s)

Practical No.12

Written By: DAIVIK SHARMA

WAP to select a random subject from a list of subjects.

import random
subjects = ['English', 'Maths', 'Physical_Education', 'Computer_Science', 'Physics', 'Chemistry']

random_index = random.randint(0, len(subjects) - 1)

random_subject = subjects[random_index]

print("Randomly Chosen Subject:", random_subject)

You might also like