-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython 12.py
More file actions
47 lines (26 loc) · 954 Bytes
/
Copy pathpython 12.py
File metadata and controls
47 lines (26 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
24. Python has many built-in functions, and if you do not know how to use it, you can read document online or find some
books. But Python has a built-in document function for every built-in functions. Please write a program to print some
Python built-in functions documents, such as abs(), int(), raw_input() And add document for your own function
Hints: The built-in document method is __doc__
# In[ ]:
def cube(num):
'Return the cube value of the input number'
return num ** 3
print cube(2)
print abs.__doc__
print int.__doc__
print raw_input.__doc__
# In[ ]:
25. Define a class, which have a class parameter and have a same instance parameter.
# In[2]:
class bird:
name='Blue'
def __init__(self,name):
self.name=name
def sing(self,song):
return f'{self.name} is singing {song}.'
bir=bird('"Green"')
print(bir.sing('"Hello"'))