Python Pioneers: A Beginner's Guide πŸ‡ͺπŸ‡Ή
8.65K subscribers
346 photos
40 videos
24 files
64 links
Welcome to Python Pioneers: Empowering Ethiopian students to embark on their coding journey.

πŸ“’ Channel: @python_pioneers
πŸ‘₯ Group: @python_pioneers_chat
Download Telegram
...continued

To access attributes or call methods on an object we use a dot-notation., the variable followed by dot and the attribute or the method name.

Syntax: the dot-notation
# Accessing an attribute
object.attribute

# Calling a method
object.method()


Example: simplified computer object
class Computer:
# __init__ is a special method (a constructor)
def __init__(self, brand, model):
# attributes
self.brand = brand
self.model = model

# methods
def powerOn(self):
print(f"Powering on {self.brand} {self.model}")

def powerOff(self):
print(f"Powering off {self.brand} {self.model}")

c1 = Computer("HP", "OMEN")
c2 = Computer("Dell", "XPS")

# Test code
print(c2.brand + " " + c2.model)
c1.powerOn()


# Output
Dell XPS
Powering on HP OMEN


#oop #PythonProgramming #DotNotation
❀1
In Python's object-oriented programming, what are the official terms used to describe an object's data and its actions?
Anonymous Quiz
46%
Variables and Functions
14%
Fields and Actions
32%
Attributes and Methods
8%
Properties and Routines
Discover a Smarter Way to Learn & Share Knowledge

As a ScholarXiv Ambassador, I’m excited to introduce you to ScholarXiv β€” a platform built for students, researchers, academics, and lifelong learners who want to discover and share scholarly knowledge.

Whether you’re working on an assignment, research project, thesis, or simply exploring a new field, ScholarXiv can help you connect with academic resources and ideas.

πŸ”¬ Research. Learn. Share. Connect.

If you’re serious about your academic journey, take a look at ScholarXiv and see what it has to offer.

πŸ‘‰ Explore: scholarxiv.com
❀2