Vous êtes sur la page 1sur 2

1. List of strings are given in the format of NAME:PHONE NUMBER.

We should print
names whose phone number is in the format such that
sum of first five digits is equal to next sum of five digits.
list=[a:1234512345,b:1234567890,c:5432154321,d:9874563210,e:9874598745]
The output should be: a,c,e which satisfies the condition.

***********************************************************************************
********************************************************************************
2. list=['ants:123','bulk:127','some:896','pile:627','shakti:190'] , keyword=akzpi
Do the followinng operations:

a) Find the position of the 'a' from 'ants', 'k' from 'bulk' and similarly for
others
b) Find the sum of digits of each elements in the list. E.g., for 'ants:123'
this element sum will be 6 and for 'bulk:127' sum will be 10 and so on.
c) Multiply the sum with the position (say 6*1=6 for first element, 10*4=40
for second and so on) and store it in a list.
d) return the list

Sample input:
list=['ants:123','bulk:127','some:896','pile:627','shakti:190'], keyword=akzpi
Sample output=[6, 40, 0, 23, 60]

***********************************************************************************
********************************************************************************

3. dict={'ram':31,'shyam':56,'karan':38,'sandy':75,'shruti':30} Do the following


operations:
a) Create a new_list with names whose age is more than 35 years.
b) The new_list should have the names without any vowels in the name.

***********************************************************************************
********************************************************************************

4. string='IND-USA-PAK/AUS-FSD-IND/FSD-IND-GVF'
return the positions of IND into output dictionary where ever it is present in
the string without counting '-' or '/'.
Example:
Output= { 'IND':[1,6,8],'USA':[2], 'PAK':[3], 'FSD':[5,7] }

***********************************************************************************
********************************************************************************
5.list=[12, 5, 36, 48, 3, 6, 8, 7, 9, 45, 50]
Do the following operartions on the list:
a) Sort the values in the list between 5 and 45 including both 5,45. E.g., [12,
5, 36, 48, 3, 6, 8, 7, 9, 45, 50] will be changed to [12, 3, 5, 6, 7, 8, 9, 36, 45,
48, 50]
b) Find the sum of the values between 5 and 45 including both 5, 45 should not
be addedd to the sum. E.g., 6+7+8+9+36=66
c) Find the sum of the rest of the values without including 5 and 45. E.g.,
12+3+48+50=179
d) Return the list with both the sum, 5, and 45
Output= [66, 179, 5,8]

***********************************************************************************
********************************************************************************

Vous aimerez peut-être aussi