Assigment 4
Assigment 4
Practical 1:
MyUdm.py:
import math
return max(a, b, c)
def Area(radius):
def Factorial(n):
if n < 0:
elif n == 0 or n == 1:
return 1
else:
factorial = 1
factorial *= i
return factorial
Code:
import MyUDM
def main():
while True:
print("5. Exit")
elif choice == 2:
max_number = MyUDM.MaxNo(a, b, c)
elif choice == 3:
Area = MyUDM.Area(radius)
elif choice == 4:
factorial = MyUDM.Factorial(number)
elif choice == 5:
break
else:
main()
Output:
1. Calculate Interest
5. Exit
1. Calculate Interest
4. Calculate Factorial
5. Exit
1. Calculate Interest
4. Calculate Factorial
5. Exit
1. Calculate Interest
4. Calculate Factorial
5. Exit
Enter a number: 2
Practical 2
StrLst.py
if len(s) > n:
return s[:n]
return s
def ShiftRight(lst):
if len(lst) == 0:
return lst
def ShiftLeft(lst):
if len(lst) == 0:
return lst
Code:
import StrLst
def main():
while True:
print("5. Exit")
if choice == 1:
result = StrLst.ShortenString(s, n)
print("Shortened String",result)
elif choice == 2:
elif choice == 3:
result = StrLst.ShiftRight(lst)
elif choice == 4:
result = StrLst.ShiftLeft(lst)
elif choice == 5:
break
else:
main()
Output:
1. Shorten String
5. Exit
1. Shorten String
5. Exit
1. Shorten String
5. Exit
Enter the string: "Everything is easy when you love what you are doing"
1. Shorten String
5. Exit
1. Shorten String
5. Exit
1. Shorten String
5. Exit
1. Calculate Interest
4. Calculate Factorial
5. Exit