#The function displayInfo will display the savings,
#the costs prior to going green, the costs after
#going green for the appropriate months
def displayInfo (notGreenCosts, goneGreenCosts, savings, months):
print
print '\t' '\t' '\t' 'SAVINGS'
print '___________________________________________________________'
print 'SAVINGS' '\t''\t' 'NOT GREEN' '\t' 'GONE GREEN' '\t' 'MONTH'
print '-----------------------------------------------------------'
print '$',savings[0], '\t','\t', '$',notGreenCosts[0], '\t','\t', '$',goneGreenCosts[0], '\t','\t', months[0]
print '$',savings[1], '\t','\t', '$',notGreenCosts[1], '\t','\t', '$',goneGreenCosts[1], '\t','\t', months[1]
print '$',savings[2], '\t','\t', '$',notGreenCosts[2], '\t','\t', '$',goneGreenCosts[2], '\t','\t', months[2]
print '$',savings[3], '\t','\t', '$',notGreenCosts[3], '\t','\t', '$',goneGreenCosts[3], '\t','\t', months[3]
print '$',savings[4], '\t','\t', '$',notGreenCosts[4], '\t','\t', '$',goneGreenCosts[4], '\t','\t', months[4]
print '$',savings[5], '\t','\t', '$',notGreenCosts[5], '\t','\t', '$',goneGreenCosts[5], '\t','\t', months[5]
print '$',savings[6], '\t','\t', '$',notGreenCosts[6], '\t','\t', '$',goneGreenCosts[6], '\t','\t', months[6]
print '$',savings[7], '\t','\t', '$',notGreenCosts[7], '\t','\t', '$',goneGreenCosts[7], '\t','\t', months[7]
print '$',savings[8], '\t','\t', '$',notGreenCosts[8], '\t','\t', '$',goneGreenCosts[8], '\t','\t', months[8]
print '$',savings[9], '\t','\t', '$',notGreenCosts[9], '\t','\t', '$',goneGreenCosts[9], '\t','\t', months[9]
print '$',savings[10], '\t','\t', '$',notGreenCosts[10], '\t','\t', '$',goneGreenCosts[10], '\t','\t', months[10]
print '$',savings[11], '\t','\t', '$',notGreenCosts[11], '\t','\t', '$',goneGreenCosts[11], '\t','\t', months[11]
0
A
回答
4
0
#The function displayInfo will display the savings,
#the costs prior to going green, the costs after
#going green for the appropriate months
def displayInfo (notGreenCosts, goneGreenCosts, savings, months):
print
print '\t' '\t' '\t' 'SAVINGS'
print '___________________________________________________________'
print 'SAVINGS' '\t''\t' 'NOT GREEN' '\t' 'GONE GREEN' '\t' 'MONTH'
print '-----------------------------------------------------------'
for i in range(12):
print '$',savings[i], '\t','\t', '$',notGreenCosts[i], '\t','\t', '$',goneGreenCosts[i], '\t','\t', months[i]
相關問題
- 1. 有沒有更好的方法來在Python中對模塊中的新類方法進行迭代編碼?
- 2. 有沒有更好的方法來處理python中的文件編碼?
- 3. 有沒有更好的方法來做這個Python代碼?
- 4. 有沒有更好的方法在Python中編寫它?
- 5. 有沒有更好的方法來編寫下面的方法?
- 6. 有沒有更好/更有效的方法來執行此SQL查詢?
- 7. 有沒有更好的方法來編寫find_messages_by_slug_or_404方法?
- 8. 有沒有更好的方法來編寫這種方法?
- 9. 有沒有更好的方法來建立此列表
- 10. 有沒有更好的方法來創建此案例查詢
- 11. 如何以更好的方式對此進行編碼
- 12. 有沒有更好的方法來對字符串進行多重替換?
- 13. 有沒有更好的方法來解壓Python中的二進制字符串
- 14. 有沒有更好的方法在python中進行日期解析呢?
- 15. 有沒有更好的方式來處理Json.Net的編碼值?
- 16. 有沒有更好的方式來編寫這段代碼?
- 17. 有沒有更好的方式在LinqToSQL中進行更新?
- 18. 有沒有更好的方法來控制子進程的PYTHONPATH?
- 19. 有沒有更好的方式來編寫這段代碼來改變從Python中的`list`繼承的對象?
- 20. 有沒有更好的方法來在angular2中有幫助者
- 21. 有沒有更好的方法來寫我的jQuery代碼?
- 22. 有沒有更好的方法來解析python文件?
- 23. Python:有沒有更好的方法來跳過測試模塊?
- 24. 有沒有更好的方法來編寫這個SQL?
- 25. 有沒有更好的方法來編寫這個函數?
- 26. 有沒有更好的方法來編寫這個SQL查詢?
- 27. 有沒有更好的方法來編寫這個jQuery腳本?
- 28. 有沒有更好的方法來編寫這組IF語句?
- 29. 有沒有更好的方法來編寫這個MySQL查詢?
- 30. 有沒有更好的方法來編寫這個jQuery?
你問如何縮短funcion?在裏面使用'for'循環。 – freakish
從來沒有聽說過循環? : -/ –
哦,我的上帝。使用你的程序員權力,循環是這些的基礎。還可以使用像pycharm這樣的IDE,它會讓生活更輕鬆。 ; P – answerSeeker