Hi 老师你好,可以写出来是怎样计算,奇数和是9,偶数和是6吗?不太明白这个算法,自己计算也算不出为何奇数和是9,偶数和是6
打印结果
老师我发现这个每执行一次所花费的时间都不一样哎 是正常的吧
a = b =a=b ()
判断a=b怎么写?
#测试私有属性,私有方法 class Employee: __company="百战程序员" def __init__(self,name,age): self.name=name self.__age=age def say_company(self): print("我的公司是:",Employee.__company) print(self.name, "年龄是: ",self.__age) self.__work() def __work(self):#私有方法 print("好好工作,好好赚钱!") p1=Employee('张三',18) print(p1.name) print(dir(p1)) p1.say_company() print(p1._Employee__age)
老师self.__work()和p1.say_company()这两句代码有点不明白
老师,在
say_score里添加age属性,是不是要 say_score被调用过之后才添加成功
not 后面跟0或者False,返回True;not后面跟1或者True,返回False。
但是not后面跟其他的都返回False,是否认为后面的内容都是True,但是后面的又不为1,怎么理解?
>>> not 30 False >>> not "123" False >>> not "abd" False >>> not "百战程序员" False
老师:
a = 20
b = a与c = copy.copy(a)的区别就是有没有创建新的对象吗
请问,b+c= 12.280000000000001 c= 9.14 是怎样计算出来的啊?谢谢。
老师您好请问一下我这个打印为什么是列表不是字典啊?格式应该没问题吧。。。
score = int(input("请输入一个分数:")) degree = 'ABCDE' num = 0 if score>100 or score<0: print("请输入一个0-100的分数:") else: num= score//10 if num<6: num=5 print(degree[9-num])
老师这个代码如果输入为100的话,输出为E
如果改成下边这个代码就应该对了
score = int(input("请输入一个分数:")) degree = 'ABCDE' num = 0 if score>100 or score<0: print("请输入一个0-100的分数:") else: num= score//10 if num==10: num=9 elif num<6: num=5 print(degree[9-num])
class Employee: id = 1000 def __init__(self,name,salary): Employee.id += 1 print(Employee.id) self.name = name self.salary = salary def __add__(self,other): if isinstance(other,Employee): return "{0}--{1}".format(self.salary, other.salary) else: return "不是同类对象,不能相加" @property def salary(self): return self.salary @salary.setter def salary(self,salary): if 1000<salary<50000: self.salary = salary else: print("录入错误!薪水在1000--5000这个范围") a = Employee("xl",3000) b = Employee("yy",5000) print(a + b)
老师,你好。我这个报错,在网上查了一下说是超过最大递归深度,按照上面的解决方法弄了一下还是不可以,麻烦老师指点一下,谢谢
class Person: def __init__(self, name, age): print("Person的构造方法") self.name = name self.age = age def say_age(self): print(self.name, "age is :", self.age) class Student(Person): # Student继承了父类Person的属性和方法 def __init__(self, name, age, score): #Person.__init__(self, name, age) super(Person, self).__init__(name, age) self.score = score s1 = Student("lxh", 23, 320) print(dir(s1)) s1.say_age()
问题乱码了,重新提交一下
老师,这两个答案都是5050,不是说从什么数字开始计算的话,变量的值也是这个数字吗,为什么不是num=1,而是num=1呢
2.我这个不知道为什么运行不了
num=sum_all=num<=: sum_all=sum_all+num num=+(sum_all)
a = 3 b =3 if a=b: print("a=b")
x=0 y=0 name=["名字","高小一","高小二","高小五"] age=["年龄",18,19,20] salary=["薪资",30000,20000,10000] list=[name,age,salary] for y in range(4): for x in range(3): list1=list[x][y] print("{0:<}".format(list1),end="\t") print() 运行结果,在30000,20000,10000 那列怎么能左对齐呢?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637