Print multiple lines in one statement without leading spaces

后端 未结 6 1445
有刺的猬
有刺的猬 2021-01-13 03:00

So for my first project it is a simple program that prints your name class you are in and what high school you went to. The one thing that is messing me up is for one of the

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-13 03:48

    How to print several lines by using one print statement and how to add new line?

    pi = 3.14159 # approximate
    diameter = 3
    radius = diameter/2
    area = pi * radius * radius
    circumference = 2 * pi * radius
    print("{}\n{}\n{}\n".format(area,radius,circumference))
    

    output:: 7.068577499999999 1.5 9.424769999999999

    the above you will get corrcet answer for this code.

提交回复
热议问题