class Book:
  def __init__(self, title="Software Engineering", isbn=""):
    self.title = title
    self.isbn = isbn
    
  def printBook(self):
    print(self.title +", "+ self.isbn)
  
  from mymodule.helper_utils import square
  print(square(100))
Ejemplo n.º 2
0
    print("The number x is positive")
elif (x<0):
    print("The number x is negative")
else:
    print("The number x is zero")
#Using loops
for i in range(5):
    print(i)
for i_idx, i_value in enumerate(range(2,10)):
    print(f"{i_idx} - {i_value}" )
#Defining and using functions
def is_even(x):
    if (x % 2) == 0:
        return True
    else:
        return False
#Defining classes
class Book:
    def __init__(self, title="Software Engineering", isbn=""):
        self.title = title
        self.isbn = isbn
def printBook(self):
    print(self.title + ", " + self.isbn)
#Define a module file
# file: mymodule.helper_utils
# A function define in the module.

#Using a module file
from mymodule.helper_utils import square
print(square(100))