P2-Python Programs
P2-Python Programs
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
. Write a Python program to generate the next 15 leap years starting from a given year. P
Explanation:
Input:
1679
Output:
[1680, 1684, 1688, 1692, 1696, 1700, 1704, 1708, 1712, 1716,
1720, 1724, 1728, 1732, 1736]
In [ ]:
In [4]:
def isanagram(st1,st2):
st1=st1.lower()
st2=st2.lower()
L1=len(st1)
L2=len(st2)
flag=True
if(L1==L2):
for ch in st1:
n1=st1.count(ch)
n2=st2.count(ch)
if(n1!=n2):
flag=False
break
else:
flag=False
return flag
#driver code
print(isanagram("CAT","CATT"))
False
In [ ]:
11. In a list of suspicious messages, the crime branch gets information that coded messag
Explanation:
Input:
number of strings and the strings
Output:
Strings starts and ends with A/a and Z/z respectively.
Sample Input:
['abcdz', 'xyzef', 'abafz', 'asdfgz','1221z']
Sample Output:
[‘bcd’,’baf’]
In [ ]:
12. Write a python program that computes the net amount of a bank account based on a tran
First line : integer t
Second line : c,n
c is to determine whether it's a deposit(D) or withdrawal (W)
n is the amount of money deposited or withdrawn
D 100
W 200
D means deposit while W means withdrawal.
Suppose the following input is supplied to the program:
4
D 300
D 300
W 200
D 100
Then, the output should be:
500
In [ ]:
6. Write a Python program to take List of numbers as elements and remove occurence of all
Sample Input :
n=5
K=3
1345
22893
16948
3334
2346
Output : [145, 2289, 16948, 4, 246]