脚本宝典收集整理的这篇文章主要介绍了2021-2022-1 20211418 《信息安全专业导论》第八周学习总结,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
[2021-2022-1信息安全专业导论](https://edu.cnblogs.com/campus/besti/2021-2022-1fois) [2021-2022-1信息安全专业导论第八周作业](https://www.cnblogs.com/rocedu/p/9577842.html#WEEK08)
本周暂无
问题1: 有一个代码照着书打,没有发现问题,但结果无法运行出来 问题1解决方案:在云班课上与同学讨论,得知是缩进出了问题,修改后就可以正常运行了。 问题2:9.7.2最后一个代码打完后正常运行但是不输出结果 问题2解决方案:经过对比教材和我的代码,发现我漏打了一个括号,导致没有引用
class Car(object): pass car = Car()
class Dog: def init(self,name,age): self.name = name self.age = age
d = Dog('Ball',2) print("Our dog's name is {0},and it is {1} years old.".format(d.name,d.age))
class Dog: def init(self,name,age,sex = 'Male'): self.name = name self.age = age self.sex = sex
d1 = Dog('Ball',2) d2 = Dog('Haha',1,'Male') d3 = Dog(name='Mop',sex = 'Male',age = 3) print("Our dog's name is {0},and it is {1} years old.".format(d1.name,d1.age,d1.sex)) print("Our dog's name is {0},and it is {1} years old.".format(d2.name,d2.age,d2.sex)) print("Our dog's name is {0},and it is {1} years old.".format(d3.name,d3.age,d3.sex))
class Account: interest_rate = 0.0568
def __init__(self,owner,amount):
self.owner = owner
self.amount = amount
account = Account('Tony',800000.0)
print('Account name:{0}'.format(account.owner)) print('Account amount:{0}'.format(account.amount)) print('Interest rate:{0}'.format(Account.interest_rate))
class Account: interest_rate = 0.0668
def __init__(self,owner,amount):
self.owner = owner
self.amount = amount
@classmethod
def interest_by(cls,amt):
return cls.interest_rate * amt
interest = Account.interest_by(12000.0) print('Calculate the interest:{0:.4f}'.format(interest))
class Account: __interest_rate = 0.0568
def __init__(self,owner,amount):
self.owner = owner
self.__amount = amount
def desc(self): print ("{0}amount:{1}interest rate:{2}.".format(self.owner,self.__amount,Account.__interest_rate))
account = Account('Tony',800000.0)
print('Account name:{0}'.format(account.owner)) print('Account amount:{0}'.format(account.amount)) print('Interest rate:{0}'.format(Account.interest_rate))
class Dog:
def __init__(self,name,age,sex = 'female'):
self.name = name
self.__age = age
def run(self):
print("{} is running...".format(self.name))
def get_age(self):
return self.__age
def set_age(self,age):
self.__age = age
dog = Dog('Ball',2) print("dog's age:{}".format(dog.get_age())) dog.set_age(3) print("the dog's age after correction:{}".format(dog.get_age()))
class Dog:
def __init__(self,name,age,sex = 'female'):
self.name = name
self.__age = age
def run(self):
print("{} is running...".format(self.name))
@property
def age(self):
return self.__age
@age.setter
def age(self,age):
self.__age = age
dog = Dog('Ball',2) print("dog's age:{}".format(dog.age)) dog.age = 3 print("the dog's age after correction:{}".format(dog.age))
class Animal:
def __init__(self,name):
self.name = name
def show_info(self):
return "Animal's name: {0}".format(self.name)
def move(self):
print("Move ...")
class Cat(Animal):
def __init__(self,name,age):
super().__init__(name)
self.age = age
cat = Cat('Tom',2) cat.move() print(cat.show_info())
class Horse: def init(self,name): self.name = name
def show_info(self):
return ("the horse's name: {0}".format(self.name))
def run(self):
print("the horse runs...")
class Donkey: def init(self,name): self.name = name
def show_infp(self):
return "the donkey's name:{0}".format(self.name)
def run(self):
print("the donkey runs...")
def roll(self):
print("the donkey rolls...")
class Mule (Horse,Donkey):
def __init__(self,name,age):
super().__init__(name)
self.age = age
m = Mule('Polly the Mule',1) m.run() m.roll() print(m.show_info())
class Horse: def init(self,name): self.name = name
def show_info(self):
return "the horse's name: {0}".format(self.name)
def run(self):
print("the horse runs...")
class Donkey: def init(self,name): self.name = name
def show_init(self):
return "the donkey's name:{0}".format(self.name)
def run(self):
print("the donkey runs...")
def roll(self):
print("the donkey rolls...")
class Mule (Horse,Donkey):
def __init__(self,name,age):
super().__init__(name)
self.age = age
def show_info(self):
return "Mule:{0},{1} years old".format(self.name,self.age)
m = Mule('Polly the Mule',1) m.run() m.roll() print(m.show_info())
class Animal: def speak(self): print("An animal is crying but we don't know what it is!")
class Dog(Animal): def speak(self): print("Puppy: WOOF...")
class Cat(Animal): def speak(self): print("Kitten:MEOW...")
an1 = Dog() an2 = Cat() an1.speak() an2.speak()
def start(obj): obj.speak()
class Animal: def speak(self): print("An animal is crying but we don't know what it is!")
class Dog(Animal): def speak(self): print("Puppy: WOOF...")
class Cat(Animal): def speak(self): print("Kitten:MEOW...")
class Car: def speak(self): print('Car:BEEP...')
start(Dog()) start(Cat()) start(Car())
i = input('Please enter a number: ') n = 8888 try: result = n / int(i) print(result) print('{0} divided by {1} is {2}'.format(n,i,result)) except: print('The number cannot be divided by zero,errpr: {}'.format(e))
i = input('Please enter a number: ') n = 8888 try: result = n / int(i) print(result) print('{0} divided by {1} is {2}'.format(n,i,result)) except ZeroDivisionError as e: print('The number cannot be divided by zero,errpr: {}'.format(e)) except ValueError as e: print('The number input is invalid,error:{}'.format(e))
i = input('Please enter a number: ') n = 8888 try: result = n / int(i) print(result) print('{0} divided by {1} is {2}'.format(n,i,result)) except (ZeroDivisionError,ValueError) as e: print('Error: {}'.format(e))
i = input('Please enter a number: ') n = 8888
try: i2 = int(i) try: result = n/12 print('{0} divided by {1} is {2}'.format(n,i2,result))
except ZeroDivisionError as e:
print('The number cannot be divided by zero,errpr: {}'.format(e))
except ValueError as e: print('The number input is invalid,error:{}'.format(e))
i = input('Please enter a number: ') n = 8888
try: result = n/int(i) print(result) print('{0} divided by {1} is {2}'.format(n,i,result)) except ZeroDivisionError as e: print('The number cannot be divided by zero,errpr: {}'.format(e)) except ValueError as e: print('The number input is invalid,error:{}'.format(e)) finally: print("Resources released...")
class ZhijieketangExcepton(Exception): def init(self,message): super().init(message)
class ZhijieketangExcepton(Exception): def init(self,message): super().init(message)
i = input('Please enter a number: ') n = 8888 try: result = n / int(i) print(result) print('{0} divided by {1} is {2}'.format(n,i,result)) except ZeroDivisionError as e: raise ZhijieketangExcepton("Can't be divided by zero.") except ValueError as e: raise ZhijieketangExcepton("Invalid number input.")
暂无。
本周学习任务还是比较重的,仍需更多时间巩固消化。
| | 代码行数(新增/累积)| 博客量(新增/累积)|学习时间(新增/累积)|重要成长| | 第一周 | 200/200 | 2/2 | 20/20 | | | 第二周 | 200/400 | 2/4 | 20/40 | | | 第三周 | 200/600 | 2/6 | 20/60 | | | 第四周 | 200/800 | 2/8 | 20/80 | | | 第五周 | 200/1000 | 2/10 | 20/100 | | | 第六周 | 200/1200 | 1/11 | 20/120 | | | 第七周 | 200/1400 | 1/12 | 20/140 | | | 第八周 | 200/1600 | 1/13 | 20/160 | | |
《计算机科学概论》《看漫画学Python》
以上是脚本宝典为你收集整理的2021-2022-1 20211418 《信息安全专业导论》第八周学习总结全部内容,希望文章能够帮你解决2021-2022-1 20211418 《信息安全专业导论》第八周学习总结所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。