Jaya
Jaya
import math
import os
import random
import re
import sys
def Reverse(lst):
lst.reverse()
return lst
# Section 2 --> Ok
rword3 = rword2[::-1]
rword3 = re.sub("\s+", "", rword3)
temp = ""
for character in rword3:
temp = temp + character + special2
print(temp[:-1])
# Section 3 --> Ok
a = True
for s in list1:
if s not in para:
a = False
if a:
print("Every string in ", end=" "),
print(list1, end=" "),
print("were present")
else:
print("Every string in ", end=" "),
print(list1, end=" "),
print("were not present")
# Section 4 --> OK
print(word1.split()[:20])
# Section 5
word_list = word1.split()
temp_dict = dict()
for str1 in word_list:
if word_list.count(str1) <= 3:
if str1 not in temp_dict:
temp_dict[str1] = 0
temp_dict[str1] += 1
temp_list = []
for value in list(reversed(list(temp_dict)))[0:20]:
temp_list.append(value)
print(Reverse(temp_list))
# Section 6
print(word1.rindex(strfind))
if __name__ == '__main__':
para = input() # a string
spch1 = input()
spch2 = input()
qw1_count = int(input().strip())
qw1 = []
for _ in range(qw1_count):
qw1_item = input()
qw1.append(qw1_item)
strf = input()
stringmethod(para, spch1, spch2, qw1, strf)
_______________________________________________________________
import math
import os
import random
import re
import sys
if __name__ == '__main__':
real1 = int(input().strip())
img1 = int(input().strip())
real2 = int(input().strip())
img2 = int(input().strip())
p1 = comp(real1, img1)
p2 = comp(real2, img2)
p1.add(p2)
p1.sub(p2)
___________________________________________________________________________________
_____
import math
import os
import random
import re
import sys
#
# Complete the 'Bank_ATM' function below.
#
# Define the Class for user-defined exceptions "MinimumDepositError" and
"MinimumBalanceError" here
class MinimumDepositError(Exception):
# Constructor method
def __init__(self, value):
self.value = value
class MinimumBalanceError(Exception):
# Constructor method
def __init__(self, value):
self.value = value
try:
if balance < 500:
raise ValueError("As per the Minimum Balance Policy, Balance must be at
least 500")
if choice == 1:
if amount < 2000:
raise MinimumDepositError("The Minimum amount of Deposit should be
2000.")
else:
isTrHappen = True
balance += amount
else:
balance -= amount
if balance < 500:
raise MinimumBalanceError("You cannot withdraw this amount due to
Minimum Balance Policy")
else:
isTrHappen = True
except ValueError as e:
print(e)
except MinimumDepositError as e:
print(e.value)
except MinimumBalanceError as e:
print(e.value)
if isTrHappen:
print("Updated Balance Amount: " + str(balance))
if __name__ == '__main__':
bal = int(input())
ch = int(input())
amt = int(input())
try:
Bank_ATM(bal, ch, amt)
except ValueError as e:
print(e)
except MinimumDepositError as e:
print(e)
except MinimumBalanceError as e:
print(e)
___________________________________________________________________________________
_____________________
import math
import os
import random
import re
import sys
#
# Complete the 'Library' function below.
#
except ValueError as e:
print(e)
except ZeroDivisionError as e:
print(e)
except NameError as e:
print(e)
if __name__ == '__main__':
memberfee = int(input())
installment = int(input())
book = input()
try:
Library(memberfee, installment, book)
except ZeroDivisionError as e:
print(e)
except ValueError as e:
print(e)
except NameError as e:
print(e)
___________________________________________________________________________________
_____________________
# MODULLE 4 CALENDER
import math
import os
import random
import re
import sys
import calendar
import datetime
from collections import Counter
#
# Complete the 'usingcalendar' function below.
#
# The function accepts TUPLE datetuple as parameter.
#
def most_frequent(List):
occurence_count = Counter(List)
return occurence_count.most_common(1)[0][0]
def usingcalendar(datetuple):
month = datetuple[1]
if calendar.isleap(datetuple[0]):
month = 2
print(calendar.month(datetuple[0], month))
obj = calendar.Calendar()
day_list = []
for day in obj.itermonthdates(datetuple[0], month):
day_list.append(day)
print(day_list[-7:])
day_name_list = []
for day in day_list:
if day.month == month:
day_name_list.append(day.strftime("%A"))
print(most_frequent(day_name_list))
if __name__ == '__main__':
qw1 = []
for _ in range(3):
qw1_item = int(input().strip())
qw1.append(qw1_item)
tup = tuple(qw1)
usingcalendar(tup)