构造方法:传入 x,y,width,height,如何做到(x,y)不传而只传 width和 height ?
怎么在IDEM中删除已经输入的之前的代码行
老师那个分式递加题,您看下我这个内存图画的正确吗,如果正确的话,n=1,返回值是多少呢
老师 为什么我的代码点击运行以后 上面写的代码就看不到了呢 只显示运行结束
老师,为什么这里print输出值不一样,上面直接输出list.sort(a)会为一个空值呢?
class Student: def __init__(self,name,score): self.name=name self.score=score def say_score(self): print("{0}的分数是:{1}".format(self.name,self.score)) s1 =Student("高琪",18) s1.say_score()
运行可以说print未解决
老师下面推导式生成的字典里面为啥值都是1
>>> dict_a = {key : value for key in 'python' for value in range(2)} >>> dict_a {'p': 1, 'y': 1, 't': 1, 'h': 1, 'o': 1, 'n': 1}
class Employee: id = 1000 def __init__(self,name,salary): self.name = name self.__salary = salary Employee.id += 1 def __add__(self, other): if isinstance(other,Employee): return "薪资和为{0}+{1}={2}".format(self.__salary,other.__salary,(self.__salary+other.__salary)) else: return "不是同类对象,无法相加!" @property def salary(self): return self.__salary @salary.setter#set方法修改私有属性的薪资 def salary(self,salary): if 1000< salary <50000: self.__salary = salary else: print("录入错误,薪资在1000-50000这个范围!") emp1 = Employee("高淇",30000) print(emp1.id) emp2 = Employee("高希希",20000) print(emp2.id) print(emp1.id)
运行截图:
提问:emp1.id在第二次打印的时候由1001变成了1002,我想emp1.id保持原来的id1001,如何解决这种问题?
#命令行模式 a = 257;b = 257 a is b True 比较 a = 257 b = 257 a is b False 这个有什么差异吗?
老师,请问我这么理解是否有问题
append增加元素的方式,是不是也创建了新的对象,他们的id都不一样了
老师,请问这是出了什么问题 #奥运五环 import turtle turtle width(10) turtle.color("blue") turtle.circle(50) turtle.color("black") turtle.penup() turtle.goto(120,0) turtle.pendown() turtle.circle(50) turtle.color("red") turtle.penup() turtle.goto(240,0) turtle.pendown() turtle.circle(50) turtle.color("yellow") turtle.penup() turtle.goto(60,-50) turtle.pendown() turtle.circle(50) turtle.color("green") turtle.penup() turtle.goto(180,-50) turtle.pendown() turtle.circle(50)
老师,这里不写return语句,直接写print不是也能出结果吗,为什么还要写return呢
>>>b ='i\'m a student'
>>>b
"i'm a student"
为什么下面会是双引号
>>>b ='i am "xiaoming"'
'i am "xiaoming"'
这里却是原样展示
score=int(input("输入一个分数(0-100):")) grade='' if score>100 or score<0: score="" else:="" if="">90: grade="A" elif score>80: grade="B" elif score>70: grade="c" elif score>60: grade="d" else: grade="e" print("分数是{0},等级是{1}".format(score,grade))
小于0时也输出东西了
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637