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

CS Practical File

The document is a practical file for a Computer Science course by Divyansh Chaturvedi, containing various programming exercises. It includes tasks such as creating lists and tuples, manipulating strings, and working with dictionaries in Python. Each task is followed by a space for code implementation, indicating the educational focus on practical coding skills.

Uploaded by

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

CS Practical File

The document is a practical file for a Computer Science course by Divyansh Chaturvedi, containing various programming exercises. It includes tasks such as creating lists and tuples, manipulating strings, and working with dictionaries in Python. Each task is followed by a space for code implementation, indicating the educational focus on practical coding skills.

Uploaded by

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

COMPUTER SCIENCE PRACTICAL FILE

Divyansh Chaturvedi XI-B


Computer Science Practical File

21. Write a program to create a list with inputs from user. Find the largest and smallest
element in the list. Also print the frequency of the smallest element. (There should be
multiple entries of smallest element).
Code:

22. Ask the user to enter a list of strings. Create a new list that consists of those strings
with their first characters removed.
Code:

23. Write a program rotates the elements of a list so that the element at the first index
moves to the second index, the element in the second index moves to the third index,
etc., and the
Code:

24. Write programs as per following specifications:


'''Print the length of the longest string in the list of strings str_list. Precondition: the list will contain
at least one element.'''
Code:

25. Write a program to accept values from a user in a tuple. Add a tuple to it and display its
elements one by one. Also display its maximum and minimum value.
Code:

Divyansh Chaturvedi XI-B Roll No.:11


Computer Science Practical File

26. Write a Python program that creates a tuple storing first 9


terms of Fibonacci series.
Code:

27. Write a program as per following specification :


"'Return the length of the shortest string in the tuple of strings str_tuple.
Precondition: the tuple will contain at least one element."' Write a program
to print roots of a quadratic equation ax^2 + bx +c=0 (where a≠0).
Code:

28. Create a tuple ('a', 'bb', 'ccc', 'dddd', ... ) that ends with 26 copies of the
letter z using a for loop.
Code:

29. Given a tuple pairs = ((2, 5), (4, 2), (9, 8), (12, 10)), count
the number of pairs (a, b) such that both a and b are even.
Code:

Divyansh Chaturvedi XI-B Roll No.:11


Computer Science Practical File

30. Write a program to print a dictionary where the keys are numbers
between 1 and 15 (both included) and values are cube of the keys.
Code:

31. Write a program to merge two dictionaries, sort the resultant dictionary and print the
sorted dictionary.
Code:

32. Create a dictionary with the roll number, name and marks of n
students in a class and display the
Code:

Divyansh Chaturvedi XI-B Roll No.:11


Computer Science Practical File

33. Repeatedly ask the user to enter a team name and how many games the team has won
and how many they lost. Store this information in a dictionary where the keys are the team
names and the values are lists of the form [wins, losses].
(a) Using the dictionary created above, allow the user to enter a team name and print out
the team's winning percentage.
(b) Using the dictionary, create a list whose entries are the number of wins
of each team. Write a program to check whether the given number is
perfect number or not.
Code:

34. Given the dictionary x = {'k1':'v1', 'k2':'v2', 'k3':'v3'}, create a dictionary with the opposite
mapping, i.e., write a program to create the dictionary as : inverted_x = {'v1': 'k1' , 'v2' :'k2' ,
'v3':'k3'}
Code:

Divyansh Chaturvedi XI-B Roll No.:11


Computer Science Practical File

Write a menu driven program to calculate:


1. Area of circle[A=πr2]
2. Area of square [A=a*a]
3. Area of rectangle[A=l*b] [A=l*b]
Code:

Divyansh Chaturvedi XI-B Roll No.:11

You might also like