Skip to content

Commit 173ae40

Browse files
committed
Boat script
1 parent c1fa2a1 commit 173ae40

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Boat.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Boat: The constructor for Boat must take a single argument denoting its maximum speed in knots. The class must be implemented to return a string based on the arg. for example, if boat is an object of class Boat with maximum speed of 82, then printing boat prints the following string "Boat with the maximum speed of 82 knots" without quotes.
3+
class Boat:
4+
"""
5+
class Boat:
6+
def __init__(self, max_speed):
7+
""" takes single arg `max_speed`, and initializes an instance variable with the same time"""
8+
self.max_speed = max_speed
9+
10+
def __str__(self):
11+
""" returnd a string that represents the object it uses an f-string to fformat the output string based on the instance variables `max_speed`"""
12+
return f"Boat with maximum speed of {self.max_speed} knots"
13+
14+
boat = Boat(int(input()))
15+
print(boat)

0 commit comments

Comments
 (0)