I.
Exception:
[Link]:
[Link] a function SUM3(L) that accepts a list L of integers and returns the sum of
those
elements who ends with digit 3.
For example : If the L contain [230, 453, 123, 92, 783, 67]
The sum should be displayed as 1359
[Link] a function Interchange (num) in Python, which accepts a list num of integers,
and
interchanges the adjacent elements of the list and print the modified list as shown
below:
(Number of elements in the list is assumed as even)
Original List: num = [5,7,9,11,13,15] After Rearrangement num = [7,5,11,9,15,13]
[Link] a function in Shift(Lst), Which accept a List ‘Lst’ as argument and swaps the
elements of every even location with its odd location and store in different list
For Example: if the array initially contains [ 2, 4, 1, 6, 5, 7, 9, 2, 3, 10 ]
then it should contain [4, 2, 6, 1, 7, 5, 2, 9, 10, 3]
4. Define a function ZeroEnding(SCORES) to add all those values in the list of
SCORES,
which are ending with zero (0) and display the sum.
For example : If the SCORES contain [200, 456, 300, 100, 234, 678]
The sum should be displayed as 600
5. Write a python program that increases the values by 10 for the dictionary alphabets
as keys and numbers as values where ever the key is a vowel.
[Link] a program that checks for presence of a value inside a dictionary and prints its
key.
info={‘Riya’: ‘CS’, ‘Mark’:’Eco’, ‘Ishpreet’: ‘Eng’, ‘Kamal’: ‘EVS’}
III.
IV. Output
Program Stack :
[Link] has created a dictionary D, containing names and salary as key value pairs of
5
employees. Write two separate functions to perform the following operations:
(a) PUSH(HS, D), where HS is the stack and D is the dictionary which containing
names
and salaries. Push the keys (name of the employee) of the dictionary into a stack,
where the corresponding value (salary) is greater than ₹75,000.
(b) POP(HS), where HS is the stack. Pop and display the content of the stack.
[Link] a function in Python PUSH(pbook), where pbook is a dictionary of phone
book(name and mobile numbers), from this dictionary push all phone numbers of
persons
whose name contains the letter ‘a’ in their names to a stack implemented by using list
and
also the display the stack if it has at least one element, otherwise display “stack
empty”
message
mydict = {‘Shyam’ : 9999123123, ‘Veena’ : 8888345345, ‘Minu’ : 9999123123,
‘Tejas’ : 7777678678}
Stack elements after push operation : [9999123123, 7777678678]
[Link] a function in Python, Store(student) where, student is a dictionary containing
the
details of students- {sname : marks}. The function should push the names of those
students
in the stack having marks more than 80. Also display the count of elements pushed
into the
stack.
4.15) A list product contains following record as list elements: [pid,pname,price]
Each of these records are nested together to form a nested list. Write the following
user
defined functions in Python to perform the specified operations on the stack named
store.
(a) Push_product(product): It takes the nested list as an argument and pushes a list
object containing name of the product and price, whose price is greater than 2500
(b) Empty_stack(): It pops the objects from the stack and displays them. Also, the
function should display "Stack Empty" when there are no elements in the stack.
[Link] has created a dictionary containing names and marks as key-value pairs of 5
students. Write a program, with separate user-defined functions to perform the
following
operations:
(a) Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70.
(b) Pop and display the content of the stack.
The dictionary should be as follows:
D = {“Ramesh”:58, “Umesh”:78, “Vishal”:90, “Khushi”:60, “Ishika”:95}
[Link] a list named Nums which contains random integers. Write the following
user
defined functions in Python and perform the specified operations on a stack named
BigNums.
(a) PushBig(): It checks every number from the list Nums and pushes all such
numbers
which have 5 or more digits into the stack, BigNums.
(b) PopBig(): It pops the numbers from the stack, BigNums and displays them. The
function should also display “Stack Empty” when there are no more numbers left in
the stack.
For example: If the list Nums contains the following data:
Nums=[213, 10025, 167, 254923, 14, 1297653, 31498, 386, 92765]
Then on execution of PushBig(),the stack BigNums should store:
[10025, 254923, 1297653, 31498, 92765]
And on execution of PopBig(), the following output should be displayed:
92765
31498
1297653
254923
10025
Stack Empty