#P0006. 太阳系八大行星
太阳系八大行星
1. Description
We can control number output format in print(), e.g.
>>> print("{0:2d}|{1:2d}".format(11, 2))
>>> 11| 2
>>> a = 12.555
>>> b = 1.2
>>> print(f"{a:7.2f}|{b:7.2f}")
>>> 12.55| 1.20
Guess the output of the code below
print("太阳系内7大行星的数据")
print("-"*60)
print("{}|水星|金星|地球|火星|木星|土星|天王星|海王星".format(" "*14))
print("-"*60)
print("到太阳的距离(AU)|{0:4.2f}|{1:4.2f}|{2:4.2f}|{3:4.2f}|{4:4.2f}|{5:4.2f}|{6:4.2f}|{7:4.2f}".format(
0.39, 0.72, 1, 1.52, 5.20, 9.58, 19.22, 30.05))
print("-"*60)
print("行星重量(EW) |{0:4.2f}|{1:4.2f}|{2:4.2f}|{3:4.2f}|{4:4.0f}|{5:4.1f}|{6:4.2f}|{7:4.2f}".format(
0.055, 0.815, 1, 0.107, 317.8, 95.2, 14.5, 17.2))
2. Input & Output
Input:
- No input for this problem
Output:
- Multiple lines of strings
- Use
print()for your output