Task In code_create_class.py, create a Student class that mo…
Task In code_create_class.py, create a Student class that models student records. Define a class Student with: __init__(self, name, student_id, gpa): stores name, student_id, and gpa as attributes. The __str__ method which returns the string representation of a student: “: – GPA: ” Example Usage/Output Usage: alice = Student(“Alice”, 12345, 3.8) print(alice) Expected Output: Alice: 12345 – GPA: 3.8
Read DetailsScenario. A division program uses try/except to handle error…
Scenario. A division program uses try/except to handle errors gracefully. If the input is not valid, meaning that it can not be typecasted into an integer, it should print “Invalid input”. Number of bugs to fix: 1 Write the complete corrected program below. try: num1 = int(input(“Enter first number: “)) num2 = int(input(“Enter second number: “)) result = num1/num2 print(result) except ZeroDivisionError: print(“Cannot divide by zero”) except ModuleNotFoundError: print(“Invalid input”) Expected output: Enter first number: A Invalid input
Read Details