Exercises
Write a program to perform the following operations using list and tuples.
Create the list
Update list using negative index Create a sub list using Slicing
Display the elements in sorting order
Delete the elements using Remove, pop, and clear
Converts a list into tuple.
Find the length, maximum and minimum value
Concatenation
Repetition
Membership Iteration
2 Write a Python program for implementing binary search on a sorted array of N numbers.
Write a python function, find_pairs_of_numbers() which accepts a list of positive integers with no repetitions and returns count of pairs of numbers in the list that adds up to n The function should return 0, if no such pairs are found in the list..
Sample Input
1,2,7,4,5,6 0,316
3,4,1,8,5,9,0,619
3 14
Expected Output
4. A teacher is in the process of generating few reports based on the marks scored by the
students of her class in a project-based assessment. Assume that the marks of her 10 students are available in a tuple. The marks are out of 25.
Write a python program to implement the following functions:
a) find more than average(): Find and return the percentage of students who have scored more than the average mark of the class.
b) generate frequency(): Find how many students have scored the same marks. For example, how many have scored 0, how many have scored 1, how many have scored 3. how many have scored 25. The result should be populated in a list and returned. c) sort marks(): Sort the marks in the increasing order from 0 to 25. The sorte
values should be populated in a list and returned
Exercises:
Write a program to perform the following operations using sets in python.
1. Find the common letters in the given sets
Find the Letters which are presented in the First set but not in the Second set and vice
versa. iii. Find the Symmetric difference between the set
iv. Find the given sets are pangram or not Count the number of vowels and constants
2. Create a Dictionary for collecting the student's details to perform the following operation.
Update Copy
iii. Remove an element
iv. Display keys and items Delete all the items
3. Care hospital wants to know the medical specialty visited by the maximum number of patients Assume that the patient id of the patient along with the medical specialty visited by the patient is stored in a list. The details of the medical specialties are stored in a dictionary as follows:
"P":"Pediatrics",
"O""Orthopedics".
EVENT
Write a function to find the medical specialty visited by the maximum number of patients and
return the name of the specialty.
Also write the pytest test cases to test the program,
Note
Assume that there is always only one medical specialty which is visited by maximum number
of patients
2. Perform case sensitive string comparison wherever necessary
Sample Input
101,0,102,0,302 P305E 401,0,656,0
101,P,102,0.302. P305P]
Expected
Output
Pediatrics
Orthopedics
101,0,102, E,302,P,305,9, 401, Ε,656,0,987,E ENT
10. Implement a python program to perform file operations
Comments
Post a Comment