Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Using Variables with Multiple Instances of a Python Class

class CoffeeOrder:
	def __init__(self, coffee_name, price):
		self.coffee_name = coffee_name
		self.price = price

lucas_order = CoffeeOrder("Espresso", 2.10)
print(lucas_order.coffee_name)
print(lucas_order.price)

paulina_order = CoffeeOrder("Latte", 2.75)
print(paulina_order.coffee_name)
print(paulina_order.price)
Source by careerkarma.com #
 
PREVIOUS NEXT
Tagged: #Using #Variables #Multiple #Instances #Python #Class
ADD COMMENT
Topic
Name
9+4 =