返回列表 發帖

格式化輸出 (一)

  1. pi=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. pi=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼
陳頡鴻

TOP

  1. pi=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼

TOP

  1. x=3.14159
  2. print("圓周率為%.2f"%x)
  3. print("圓周率為%.4f"%x)
  4. print("圓周率為%05.2f"%x)
  5. print("圓周率為%f"%x)
  6. print("圓周率為%d"%x)
  7. print("圓周率為%s"%x)
複製代碼

TOP

  1. pi=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼

TOP

  1. pi=3.1415926
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼

TOP

  1. x=3.14159
  2. print("圓周率為%.2f"%x)
  3. print("圓周率為%.4f"%x)
  4. print("圓周率為%05.2f"%x)
  5. print("圓周率為%5f"%x)
  6. print("圓周率為%.0f"%x)
  7. print("圓周率為%.5f"%x)
複製代碼

TOP

  1. pi=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼

TOP

  1. a=123.123
  2. b="C"
  3. print("AB%sD"%b)
  4. print("★%d★"%a)
  5. print("★%f★"%a)
  6. print("~~~~%6.3f~~~"%a)
  7. print("~~~~%01.2f~"%a)
  8. print("~~~~%07.2f~"%a)
  9. print("~~~~%08.2f~"%a)
複製代碼

TOP

  1. pi = 3.14159

  2. print("圓周率為%.2f"%pi)

  3. print("圓周率為%.4f"%pi)

  4. print("圓周率為%05.2f"%pi)

  5. print("圓周率為%f"%pi)

  6. print("圓周率為%d"%pi)

  7. print("圓周率為%s"%pi)
複製代碼

TOP

  1. pi=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼

TOP

  1. pi=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼

TOP

  1. x=3.141593
  2. print("圓周率為%.2f"%x)
  3. print("圓周率為%.4f"%x)
  4. print("圓周率為%05.2f"%x)
  5. print("圓周率為%f"%x)
  6. print("圓周率為%s"%x)
複製代碼

TOP

  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Sat Feb  1 11:50:10 2020

  4. @author: student
  5. """

  6. aa=3.14
  7. print("圓周率%.3f"%aa)
  8. print("圓周率%5.3f"%aa)
  9. print("圓周率%7.1f"%aa)
  10. print("圓周率%f"%aa)
  11. print("圓周率%d"%aa)
  12. print("圓周率%s"%aa)
  13. print("圓周率%08.4f"%aa)
複製代碼

TOP

  1. pi=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼

TOP

  1. x=3.14159
  2. print("圓周率為%.2f"%x)
  3. print("圓周率為%.4f"%x)
  4. print("圓周率為%05.2f"%x)
  5. print("圓周率為%5f"%x)
  6. print("圓周率為%.0f"%x)
  7. print("圓周率為%.5f"%x)
複製代碼

TOP

  1. i=3.14159
  2. print("圓周率為%.2f"%pi)
  3. print("圓周率為%.4f"%pi)
  4. print("圓周率為%05.2f"%pi)
  5. print("圓周率為%f"%pi)
  6. print("圓周率為%d"%pi)
  7. print("圓周率為%s"%pi)
複製代碼

TOP

返回列表