Question: Write a class player with attributes name, age and sport. Create methods in the class to set and get each attribute such as setName(name) and
Write a class "player" with attributes "name", "age" and "sport". Create methods in the class to set and get each attribute such as setName(name) and getName() to set and obtain the name of the player's object. Similarly write set and get methods for all the attributes of the class. However, this class is restricted to single sport, so make "sport" variable static.
For example:
Test:
p1 = player("Ronaldo",37)
print(p1.getName())
Result:
Ronaldo
Step by Step Solution
There are 3 Steps involved in it
Python class Player sport Football def initself name age selfname name selfage age def getNameself r... View full answer
Get step-by-step solutions from verified subject matter experts
