标题:一个关于中华人民共和国的小程序
只看楼主
风卷浪起
Rank: 3Rank: 3
来 自:中国福建福州福清
等 级:论坛游侠
威 望:4
帖 子:125
专家分:129
注 册:2021-11-13
结帖率:83.33%
 问题点数:0 回复次数:4 
一个关于中华人民共和国的小程序
class China:
    def __init__(self, cover, pollution):
        self.cover = cover
        self.pollution = pollution
        print(f"\tChina has about {self.cover} covers.")
        print(f"China has about {self.pollution} pollutions.")
        
    def moutains(self):
        print("\tChina has a lot of moutains.")
        
    def famous_moutain(self):
        print("Mount Huang is famous.")
        
    def rivers(self):
        print("\tChina has a lot of rivers, too.")
        
    def famous_river(self):
        print("And Huanghe river, Yangze river is famous, too.")
        
    def love_China(self):
        print("\tI love China!")
        
the_China = China(9600000, 1400000000)
the_China.moutains()
the_China.famous_moutain()
the_China.rivers()
the_China.famous_river()
the_China.love_China()

这是我无聊时写的一个小程序,欢迎大家点评(运行时无错误)!比如可以简化一些部分吗?
搜索更多相关主题的帖子: 小程序 print def China 运行 
2021-11-28 11:39
风卷浪起
Rank: 3Rank: 3
来 自:中国福建福州福清
等 级:论坛游侠
威 望:4
帖 子:125
专家分:129
注 册:2021-11-13
得分:0 
还有一个版本:
class China:
    def __init__(self):
        print("\tChina is so great!")
        
    def coverpollution(self, cover, pollution):   
        self.cover = cover
        self.pollution = pollution
        print(f"\tChina has about {self.cover} covers. ", end = '')
        print(f"China has about {self.pollution} pollutions.")
        
    def moutains(self):
        print("\tChina has a lot of moutains.")
        
    def famous_moutain(self):
        print("Mount Huang is famous.")
        
    def rivers(self):
        print("\tChina has a lot of rivers, too.")
        
    def famous_river(self):
        print("And Huanghe river, Yangze river is famous, too.")
        
    def love_China(self):
        print("\tI love China!")
        
the_China = China()
the_China.coverpollution(9600000,1400000000)
the_China.moutains()
the_China.famous_moutain()
the_China.rivers()
the_China.famous_river()
the_China.love_China()

追阳少年也会身披万丈光芒。
2022-01-18 20:11
储备
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2022-1-23
得分:0 
2022-01-23 08:32
风卷浪起
Rank: 3Rank: 3
来 自:中国福建福州福清
等 级:论坛游侠
威 望:4
帖 子:125
专家分:129
注 册:2021-11-13
得分:0 
怎么样?

追阳少年也会身披万丈光芒。
2022-02-06 12:15
sssooosss
Rank: 9Rank: 9Rank: 9
等 级:禁止访问
威 望:3
帖 子:664
专家分:1115
注 册:2019-8-27
得分:0 
共同进步
2022-03-04 18:41



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-507676-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.067489 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved