Answers for "python class to string"

0

python class to string

def __str__(self):
     return "foo"
Posted by: Guest on March-18-2021
0

string representation of object python

#!/bin/python3

import math
import os
import random
import re
import sys

class Car:
    def _init_(self,speed,unit):
        self.speed=speed
        self.unit=unit
    def __str__(self):
        return "Car with the maximum speed of {} {}".format(self.speed,self.unit)  

class Boat:
    def _init_(self,speed):
        self.speed=speed
    def __str__(self):
        return "Boat with the maximum speed of {} knots".format(self.speed)
Posted by: Guest on November-19-2020

Code answers related to "python class to string"

Python Answers by Framework

Browse Popular Code Answers by Language