Method of Outputting Multiple Formatting Parameters with print of in python
- 2021-07-18 08:33:45
- OfStack
No nonsense, just post the code:
disroot = math.sqrt(deta)
root1 = (-b + disroot)/(2*a)
root2 = (-b - disroot)/(2*a)
print(" There are two different solutions : %.2f,%.2f"%root1,%root2)
This is the original print () code, but the runtime always prompts TypeError
Later, I searched a lot of information on the Internet and found that the format was not like this at all, which I took for granted
disroot = math.sqrt(deta)
root1 = (-b + disroot)/(2*a)
root2 = (-b - disroot)/(2*a)
print(" There are two different solutions : %.2f,%.2f"%(root1,root2))