what is a constructor in python code example

Example 1: python class constructor

class Human:
	def __init__(self, name):
      self.name = name

h1 = Human("Bob")
print(h1.name) # prints Bob, the name passed from constructor

Example 2: pyhon constructor

def __init__(self):
    # body of the constructor

Example 3: how to define function in python

def example():			#This defines it
  print("Example.")		#This is the defined commands

example()				#And this is the commands being run

Example 4: what is a tuple in python

# A tuple is a sequence of immutable Python objects. Tuples are
# sequences, just like lists. The differences between tuples
# and lists are, the tuples cannot be changed unlike lists and
# tuples use parentheses, whereas lists use square brackets.
tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = "a", "b", "c", "d";

# To access values in tuple, use the square brackets for
# slicing along with the index or indices to obtain value
# available at that index.
tup1[0] # Output: 'physics'