Lab 5- Colab
Lab 5- Colab
keyboard_arrow_down Question 1
class account:
def __init__(self,a,b,c):
self.name=a
self.account=b
self.belance=c
def info(self):
print("Account owner is ",self.name)
print("Account number is ",self.account)
print("Your Udhar is ",self.belance)
def withdraw(self):
account=int(input("How much Udhar you want: "))
if account<self.belance:
print("Withdraw Sucessfull")
print(f"Updated Udhar {self.belance+account}")
else:
print("Insufient Balance")
def deposit(self):
y=int(input("How much Udhar you want return: "))
print("Udhar returned Sucessfully")
print(f"Updated Udhar {self.belance-y}")
keyboard_arrow_down Question #2
class employee:
def __init__(self,a,b):
self.name=a
self.position=b
def info(self):
print("Employee name is ",self.name)
print("Employee position is ",self.position)
class manager(employee):
def __init__(self,a,b,c):
self.name=a
self.team=b
self.team_member=c
def info(self):
print("Manager name is ",self.name)
print("Manager team is ",self.team)
print("Manager team member is ")
self.team_member.info()
class director:
def __init__(self,a,b,c):
self.name=a
self.department=b
self.department_manager=c
def info(self):
print("Director name is ",self.name)
print("Director department is ",self.department)
print("Director department manager is ")
self.department_manager.info()
saif=employee("saif","programmer")
saif.info()
mudassar=manager("mudassar","python",saif)
mudassar.info()
hassan_ejaz=director("hassan ejaz","Mechanical",mudassar)
hassan_ejaz.info()
keyboard_arrow_down task 3
class Question:
def __init__(self, text, options, correct_option):
self.text = text
self.options = options
self.correct_option = correct_option
class Player:
def __init__(self, name):
self.name = name
class Quiz:
def __init__(self, questions):
self.questions = questions
try:
player_answer = int(input("\nYour answer (enter option number): "))
if player_answer < 1 or player_answer > len(question.options):
print("Invalid option selected. Please try the next question.\n")
continue
except ValueError:
print("Please enter a valid number for the option.\n")
continue
if question.is_correct(player_answer):
print("Correct!\n")
score += 1
else:
print(f"Wrong! The correct answer was {question.correct_option}\n")
if __name__ == "__main__":
question1 = Question("What is the capital of Pakitan?", ["Paris", "London", "Islambad", "Rome"], 3)
question2 = Question("who is Ronano Zoro?", ["Navy", "Pirte", "Younko", "nothing"], 2)
question3 = Question("Which planet is known as the Red Planet?", ["Earth", "Mars", "Jupiter", "Saturn"], 2)
quiz = Quiz(questions)
player = Player(name="Saif")
quiz.conduct_quiz(player)