аватар question@mail.ru · 01.01.1970 03:00

F-String transfer by PEP

I decided to follow the writing of my code and faced the problem of how to make the transfer of lines and expressions in Python.

   def   get_message  ( self ) -& gt;  str :   retu   f'etip training:  {self.training_type} ; Duration:  {Self.Duration: . 3  f}  h.; Distance:  {self.distance: . 3  f}  km; Cf. Speed:  {self.speed: . 3  f}  km/h; The kcal was spent:  {self.calories:  f} . '     
   Def   get_spent_calories  ( self ) -& gt;  float :    mean_Speed ​​= self.get_mean_Speed ​​()   Retu  (Self.coeff_calorie_1 * mean_Speed ​​- self.coEFF_CALORIE_2) * SELF.WEIT / SELF.M_IN_KM * SELF.DUURATIONS * SELF.H_IN_MIN  

How to make a string transfer (did not exceed 79 characters) in the console the conclusion should be in one line. I apologize in advance for such a stupid question)

аватар answer@mail.ru · 01.01.1970 03:00

Why not contact:

The Preferred Way of Waypping Lines IS by Using Impled Line Continition INSIDE PARENTHESS, BRACKETS and BRACES. LONG Lines Can Broken Over Multiple Lines by Wraphing Expressions in Parentheses. Tenes shoup ​​be used in preference to using a backslash for line contact.

PRITIONAL METHOD OF TRASION OF LONG LANDS is Python lines inside brackets, brackets and curly brackets. Long lines can be divided into several lines, enclosing expressions into round brackets. They should be used instead of using a reverse oblique feature to continue the line.

Example:

   DEF   get_message  ( self ) -& gt;  str :   retu  ( f'etip training:  {self.training_type} ; '   f'dliness:  {Self.Duration: . 3  f}  h. '   f'dista:  f}  km;    f'sr Class = "">. 3  f}  km/h;    f'p -trained kcal:  {seelf.calories: . 3  f} . ')  

ps In addition to compliance with the PEP-8 standards, the code should be easily readable. Therefore, I broke the lines in this way.

Latest

Similar