为了账号安全,请及时绑定邮箱和手机立即绑定
from math import *
print(sin(0))
print(cos(0))
# common.py
def say_hello(name):
print('Hello,{}'.format(name))
say_hello('LiuYF')
class Fib(object):
def __init__(self):
self.res = []
def __call__(self,num):
for i in range(num):
self.res.append(i)
if i > 1:
self.res[i] = self.res[i - 1] + self.res[i - 2]
return self.res
f = Fib()
print(f(10))
class Student(object):
def __init__(self,name,ge):
self.name = name
self.ge = ge
def __str__(self):
return 'Student: {},{}'.format(self.name,self.ge)
def __repr__(self):
return 'Student:{},{}'.format(self.name,self.ge)
s = Student('忆雪','女',88)
print(s)
# -*- coding: utf-8 -*-
class Person(object):
def __init__(self,name,gender):
self.name = name
self.gender = gender
class Teacher(Person):
def __init__(self,name,gender,su):
super(Teacher,self).__init__(name,gender)
self.su= su
teacher = Teacher('弘','男','历')
class Animal(object):
def __init__(self,name,age,location):
self.__name = name
self.__age = age
self.__location = location
def g(self):
return 'n = {}, a = {}, l = {}'.format(self.__name,self.__age,self.__location)
dog = Animal('T',5,'A')
print(dog.g())
class Animal(object):
_count = 0
def __init__(self,name,age):
self.name = name
self.age = age
Animal._count += 1
dog = Animal('kg',12)
print(dog._count)
print(Animal._count)
class Animal(object):
def __init__(self,name,age):
self.name = name
self.age = age
dog = Animal('Tom',3)
cat = Animal('Lily',2)
print(dog.name)
print(dog.age)
print(cat.name)
print(cat.age)

最新回答 / 史洁_glntBJ
将光标移动到文件末尾
class Animal(object):
pass

dog = Animal()
cat = Animal()
print(dog)
print(cat)
print(dog == cat)

最新回答 / 慕容0245657
"用pow()实现的话,该怎么写?"什么需求需要用pow()实现
静态,方法,类访问

最新回答 / tinghai
执行报错:Traceback (most recent call last):  File "E:\python\example\lizi.py", line 283, in <module>    student = Student('Alice',100)              ^^^^^^^^^^^^^^^^^^^^  File "E:\python\example\lizi.py", line 280, in __init__    super(Student, self).__i...
这个精度问题搞得人有点懵,还以为错了呢
‌repr是“representation”的缩写,意为“表示”或“表达”‌。
super详解:https://www.runoob.com/w3cnote/python-super-detail-intro.html
课程须知
本课程是Python入门的后续课程 1、掌握Python编程的基础知识 2、掌握Python函数的编写 3、对面向对象编程有所了解更佳
老师告诉你能学到什么?
1、什么是函数式编程 2、Python的函数式编程特点 3、Python的模块 4、Python面向对象编程 5、Python强大的定制类

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消