Wednesday, July 28, 2021

Classes, Objects, and Properties in Python

 A simple program that I wrote using Python programming language to show how to declare and use classes, objects, and propertines.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Program Listing

# mod6_act1.py
# Author : Jake R. Pomperada

class Car:
color = "Red"
model = "Everest"
manufacturer = "Ford"

def __init__(self, kulay, modelo, tagagawa):
self.col = kulay
self.mod = modelo
self.man = tagagawa


car1 = Car("Blue", "Fortuner", "Ford")
car2 = Car("White", "mu-X", "Isuzu")
car3 = Car("Brown", "Terra", "Nissan")

print(f"Car color is {car1.color}, Model is {car1.model}, Manufacturer is {car1.manufacturer}")
print("=========After modifying the properties===========")
print(f"Car color is {car1.col}, Model is {car1.mod}, Manufacturer is {car1.man}")
print(f"Car color is {car2.col}, Model is {car2.mod}, Manufacturer is {car2.man}")
print(f"Car color is {car3.col}, Model is {car3.mod}, Manufacturer is {car3.man}")


No comments:

Post a Comment