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

Practical_File

Uploaded by

leon31king
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Practical_File

Uploaded by

leon31king
Copyright
© © All Rights Reserved
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: YUGANDHAR YUG
Roll Number: 45
Class & Section: 11th-D

Rosary Senior Secondary School


Radio Colony, Kingsway Camp
Delhi – 110009
INDEX
S.n Practical Description 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.
Program No. 1
Developed By: Yugandhar Yug
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)

Program No.2

Developed By: Yugandhar Yug

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)

Program No.3

Developed By: Yugandhar Yug

WAP to implement Linear Search on a list of numbers.


Source Code:

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.")

Program No.4

Developed By: Yugandhar Yug

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

Source Code:

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")

Program No.5

Developed By: Yugandhar Yug


WAP to input a list of numbers and swap elements at the even location with the
elements at the odd location.

Source Code:

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)

Program No.6

Developed By: Yugandhar Yug

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.

Source Code:

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)

Program No.7

Developed By: Yugandhar Yug

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

Source Code:
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)

Program No.8

Developed By: Yugandhar Yug

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.

Source Code:

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'])

Program No.9

Developed By: Yugandhar Yug


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

Source Code:

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")

Program No.10

Developed By: Yugandhar Yug

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


salary of each employee and display.

Source Code:

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']}")

Program No.11

Developed By: Yugandhar Yug

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

Source Code:

SSfrom math import sqrt


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

Program No.12

Developed By: Yugandhar Yug

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

Source Code:

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