Python Programming - Objects - Discussion

Discussion Forum : Objects - General Questions (Q.No. 25)
25.
Consider the following Python code:
class Employee:
    def __init__(self, name, salary):
        self.name = name
        self.salary = salary

    def give_raise(self, amount):
        self.salary += amount
If you create an instance of the `Employee` class called john with a salary of 50000 and then call john.give_raise(5000), what will be the updated salary?
55000
5000
45000
None
Answer: Option
Explanation:
The give_raise method increases the salary attribute by the specified amount. In this case, it would be 50000 + 5000 = 55000.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.