World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITian's, only for AI Learners.
Designed by IITian's, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Download our e-book of Introduction To Python
4.5 (1,292 Ratings)
559 Learners
Jigisha Sata
a year ago
def print_func( par ):
print ("Hello: ", par)
return
#!/usr/bin/python3
# Import module hello
import hello
# Now you can call a defined function that module as follows
hello.print_func("USER")
Hello: User
#!/usr/bin/python3
# Fibonacci numbers module
def fibo(n): # return Fibonacci series up to n
result = []
a, b = 0, 1
while b < n:
result.append(b)
a, b = b, a + b
return result
>>> from fibo import fibo
>>> fibo(100)
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
#!/usr/bin/python3
# Fibonacci numbers module
def fibo(n): # return Fibonacci series up to n
result = []
a, b = 0, 1
while b < n:
result.append(b)
a, b = b, a + b
return result
if __name__ == "__main__":
f = fibo(100)
print(f)
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
#!/usr/bin/python3
Income= 2000
def AddIncome():
# Uncomment the following line to fix the code:
# global Income
Income = Income + 1
print (Income)
AddIncome()
print (Income)
#!/usr/bin/python3
# Import built-in module math
import math
content = dir(math)
print (content)
['__doc__', '__file__', '__name__', 'acos', 'asin', 'atan',
'atan2', 'ceil', 'cos', 'cosh', 'degrees', 'e', 'exp',
'fabs', 'floor', 'fmod', 'frexp', 'hypot', 'ldexp', 'log',
'log10', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh',
'sqrt', 'tan', 'tanh']
#!/usr/bin/python3
def Pots():
print ("I'm Pots Phone")
from Pots import Pots
from Isdn import Isdn
from G3 import G3
#!/usr/bin/python3
# Now import your Phone Package.
import Phone
Phone.Pots()
Phone.Isdn()
Phone.G3()
I'm Pots Phone
I'm 3G Phone
I'm ISDN Phone