Board logo

標題: 格式化輸出 (一) [打印本頁]

作者: 陳品肇    時間: 2020-2-1 09:39     標題: 格式化輸出 (一)

[attach]8338[/attach]
  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)
複製代碼

作者: 陳頡鴻    時間: 2020-2-1 11:50

  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)
複製代碼

作者: 黃紹綸    時間: 2020-2-1 11:53

  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)
複製代碼

作者: 李穎俊    時間: 2020-2-1 11:53

  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)
複製代碼

作者: 潘堉恩    時間: 2020-2-1 11:54

  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)
複製代碼

作者: 陳沛頤    時間: 2020-2-1 11:54

  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)
複製代碼

作者: 曾柏忻    時間: 2020-2-1 11:55

  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)
複製代碼

作者: 林依玟    時間: 2020-2-1 11:55

  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)
複製代碼

作者: 張鈞堯    時間: 2020-2-1 11:56

  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)
複製代碼

作者: 黃紹恩    時間: 2020-2-1 11:56

  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)
複製代碼

作者: 曾顗文    時間: 2020-2-1 11:57

  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)
複製代碼

作者: 傅英哲    時間: 2020-2-1 11:57

  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)
複製代碼

作者: 許雅棟    時間: 2020-2-1 11:57

  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)
複製代碼

作者: 黃柏叡    時間: 2020-2-1 11:59

  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)
複製代碼

作者: 傅品翰    時間: 2020-2-1 12:00

  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)
複製代碼

作者: 林奇陞    時間: 2020-2-1 12:01

  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)
複製代碼

作者: 鍾金恩    時間: 2020-2-1 12:27

  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)
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/) Powered by Discuz! 7.2