A Beginner's Python Tutorial - Importing Modules - Wikibooks, Open Books For An Open World
A Beginner's Python Tutorial - Importing Modules - Wikibooks, Open Books For An Open World
Tutorial/Importing
Modules
< A Beginner's Python Tutorial
def timesfour(input):
print(input * 4)
# define a class
class Piano:
def __init__(self):
self.type =
input("What type of piano?
")
self.height =
input("What height (in
feet)? ")
self.price =
input("How much did it
cost? ")
self.age =
input("How old is it (in
years)? ")
def printdetails(self):
print(f'This
piano's height is
{self.height} foot')
print(self.type,
"piano, " + self.age,
"years old and costing\
" + self.price + "
dollars.")
### mainprogam.py
### IMPORTS ANOTHER MODULE
import moduletest
# import them
from moduletest import
ageofqueen
from moduletest import
printhello
Retrieved from
"https://en.wikibooks.org/w/index.php?
title=A_Beginner%27s_Python_Tutorial/Importing_
Modules&oldid=3842740"
This page was last edited on 6 June 2021, at
14:46. •
Content is available under CC BY-SA 4.0 unless
otherwise noted.