Hello!
Today it is going to be an python explatnation!
Today's question:
Create a class that takes the following four arguements for a particular football player:
name
age
height
weight
Also, create three functions for the class that returns the following strings:
get_age()
returns "name
is ageage
"get_height()
returns "name
isheight
cm"get_weight()
returns "name
weighsweight
kg"Examples
p1 = player("David Jones", 25, 175, 75) p1.get_age() ➞ "David Jones is age 25" p1.get_height() ➞ "David Jones is 175cm" p1.get_weight() ➞ "David Jones weighs 75kg
My code!
Let's see.
There is four instances : Name, Age, height, weight in a class called player.
Next, we have 3 functions,
The first function is about the age off the foot ball player.
You can return the name and the age.
So, you can use format to put the name, and the age.
The second function is similar, return the name and the height.
You can use format to take the name and the height.
It's the same pattern, the third function is to return the name and the weight.
Use the format to take the name and the weight.
It was easy!!!!!
Bye!!!!!
0 件のコメント:
コメントを投稿