K
K
Kamral Magaramov2022-04-13 18:40:09
Python
Kamral Magaramov, 2022-04-13 18:40:09

How to create class objects for Class InfoMessafe using the show_training_info() method found in the Training base class?

InfoMessage class properties:
training_type — training class name;
duration — duration of the workout in hours;
distance — distance in kilometers that the user covered during the training;
speed - the average speed at which the user moved;
calories - the number of kilocalories that the user has consumed during the workout.

""" Class InfoMessage
from typing import Union

class InfoMessage:
'''IngoMessage Class Variables'''
training_type:str
duration:Union[int,float]
distance:Union[int,float]
speed:Union[int,float]
calories :Union[int,float]

def __init__(self, training_type,duration,distance,speed, calories):
self.training_type=training_type
self.duration=duration
self.distance=distance
self.speed=speed
self.calories=calories

def get_message(self)->str:
return (f'Training type: {self.training_type};'
f'Duration:{self.duration:.3f} h;'
f'Distance: {self.distance:.3f} km;'
f'Average speed: { self.speed:.3f};'
f'Calories expended:{self.calories:.3f}')

class Training:
'''distance traveled by an athlete in one step or stroke'''
LEN_STEP:Union[int,float]=0.65
'''constant to convert values ​​from meters to kilometers. Its value is 1000'''
M_IN_KM:int=1000
'''number of actions taken (number of steps
when walking and running or strokes when swimming);
'''
action:int
'''training duration;'''
duration:float
''' weight of the athlete.'''
weight:float

def __init__(self, action, duration, weight)->None:
self.action=action
self.duration=duration
self.weight=weight

def get_distance(self)->Union[int,float]:
'
'''
result=self.action*self.LEN_STEP/self.M_IN_KM return
result

def get_mean_speed(self)->Union[int,float]:
'''returns the value of the average movement speed during the workout. '''
mean_spead=self.action*self.LEN_STEP/self.duration
return mean_spead

def get_spent_calories(self)->None:
'''Returns the number of kilocalories expended during training'''
pass

def show_training_info(self)->InfoMessage :
pass

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question