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

1 Expert Approved Answer
Step: 1 Unlock

Python class Player sport Football def initself name age selfname name selfage age def getNameself r... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!