Lab Programms
Lab Programms
for i in range(3,int(n**0.5),2):
while n % i == 0:
maxPrime = i
n = n/i
if n > 2:
maxPrime = n
if maxPrime == -1:
print("No Prime Factor Found")
else:
print("Max Prime Factor : ", maxPrime)
2)
# Declare a value
a = -16
3)
4)
while True:
print('\n===== MENU =====')
print('1. Insert at Specific Position')
print('2. Remove Element from the List')
print('3. Add Element to the List')
print('4. Display the List')
print('5. Exit\n')
if choice == 1:
position = int(input('Enter the position to insert: '))
item = int(input('Enter the item to insert at the given position:
'))
if 0 <= position <= len(numbers):
numbers.insert(position, item)
else:
print("Invalid position")
elif choice == 2:
if numbers:
position = int(input('Enter the position to delete an item:
'))
if 0 <= position < len(numbers):
numbers.pop(position)
else:
print("Invalid position")
else:
print("List is empty")
elif choice == 3:
item = int(input('Enter an item to add: '))
numbers.append(item)
elif choice == 4:
print("======= List Content =======")
print(numbers)
elif choice == 5:
print('Exiting.....')
break
else:
print("Invalid Choice. Please choose a valid option.")
6)
Employee = {}
while True:
print("\nEmployee Database Menu:")
print("1. Create Employee")
print("2. Add New Employee")
print("3. Search Employee")
print("4. Delete Employee")
print("5. Display")
print("6. Exit")
if Choice == 1:
n = int(input('Enter the Number of Employees: '))
for i in range(n):
print("\nEnter the Employee {0} Details".format(i+1))
EmpId = int(input("Enter the Employee ID: "))
EmpDetails = []
EmpName = input("Enter the Employee Name: ")
EmpDOB = input("Enter the DOB: ")
Designation = input("Enter the Designation: ")
EmpDetails.append(EmpName)
EmpDetails.append(EmpDOB)
EmpDetails.append(Designation)
Employee[EmpId] = EmpDetails
elif Choice == 2:
EmpId = int(input('Enter the Employee ID: '))
EmpDetails = []
EmpName = input('Enter the Employee Name: ')
EmpDOB = input('Enter the DOB: ')
Designation = input('Enter the Designation: ')
EmpDetails.append(EmpName)
EmpDetails.append(EmpDOB)
EmpDetails.append(Designation)
Employee[EmpId] = EmpDetails
elif Choice == 3:
EmpId = int(input('Enter the Employee ID to Display: '))
print(Employee.get(EmpId))
elif Choice == 4:
EmpId = int(input('Enter the Employee ID to Delete: '))
print(Employee.pop(EmpId))
elif Choice == 5:
Status = bool(Employee)
if Status == False:
print("No Employee Details Found to Print")
else:
print(Employee)
elif Choice == 6:
print("Exiting Employee Database.")
break
else:
print("Invalid Choice")
7)
setdata = set()
tupledata = tuple()
while True:
choice = input("Enter your Choice\nS: Set Operation\nT: Tuple
Operation\nN: Terminate\n")
if choice == 'S':
while True:
print("Choose The Set Operation")
print('1. Add/Insert')
print('2. Remove/Delete')
print("3. Update/Append")
print("4. Display/View")
print("0. Exit")
operation = input()
if operation == 1:
data = input("Enter the element to add : ")
setdata.add(data)
print(setdata)
elif operation == 2:
data = input("Enter the element to remove :")
setdata.discard(data)
print(setdata)
elif operation == 3:
data = input("Enter the Element to update : ")
setdata.update([data])
elif operation == 4:
print(setdata)
elif operation == 0:
break
else:
print("Invalid Choice")