第三次
import math
def area_circle(r): return math.pi * r ** 2
def main():
r = float(input(
r'Please enter a radius of the circle that you want to calculate its area: '))
assert r > 0, r'Radius should be larger than zero.'
print(r'The area of the circle is ', area_circle(r), r'.', sep=r'')
main()
第四次
class Card(object):
pass
class IC(Card):
pass
class CampusCard(IC):
def __init__(self, id=None):
if id == None:
id = 0
self.__id = id
self.__balance = 0
@property
def id(self):
return self.__id
def __repr__(self):
return str(self.__id).rjust(7, r'0')
def charge(self, amount):
self.__balance += amount
def comsume(self, amount):
self.__balance -= amount
def report_of_loss(self):
print(r'Loss', self.__id, self.__balance)
网友评论