Online · Subang Jaya · Selangor

AI Logic and STEM Creative Workshops for Subang Jaya Students

AI logic and STEM creative workshops for Subang Jaya students introduce computer vision, pattern recognition and machine-learning ideas through kid-friendly visual tools—plus responsible AI habits.

AI STEM Subang Jaya

1. Introduction: From Definition to Access

In previous topics, we learned that when defining a class, we use the self keyword to create instance variables and instance methods. Instance methods can access and manipulate those specific instance variables.

Once a class blueprint is compiled and objects are instantiated, the next critical step is knowing how to access those instance variables and invoke their instance methods from outside the class.

2. Reviewing the Student Class Architecture

To demonstrate accessing attributes and methods, we utilize the Student class. This blueprint packages three instance variables and three instance methods:

  • Three instance variables: self.name, self.age, self.grade (identified as instance variables because each is prefixed with self. inside the constructor).
  • Three instance methods:
    • __init__(self, name, age, grade) — the constructor
    • display_info(self) — displays all three instance variables
    • is_eligible(self) — uses an if-else condition to evaluate whether the student's age is greater than 15

We identify them as instance methods because each accepts self—the object on which the method is called—as its first parameter.

class Student:
    # 1. Constructor initializing instance attributes
    def __init__(self, name, age, grade):
        self.name = name
        self.age = age
        self.grade = grade

    # 2. Instance method to display all details
    def display_info(self):
        print("Name:", self.name)
        print("Age:", self.age)
        print("Grade:", self.grade)

    # 3. Instance method evaluating admission eligibility
    def is_eligible(self):
        if self.age > 15:
            print(f"{self.name} is eligible for admission.")
        else:
            print(f"{self.name} is not eligible for admission.")

When this class cell is executed in Jupyter Notebook, Python registers the template into memory.

3. Instantiating Multiple Distinct Objects

From this single template, we instantiate two independent student objects: student1 and student2:

# Instantiating student1: Name Ali, Age 16, Grade 10th
student1 = Student("Ali", 16, "10th")

# Instantiating student2: Name Sara, Age 14, Grade 8th
student2 = Student("Sara", 14, "8th")

Both objects now exist in memory with their respective attributes configured.

4. Accessing Instance Variables Directly

To read an object's instance variable directly from outside the class, use the dot operator (.) by writing the object name, followed by a dot, followed by the attribute name:

# Accessing student1's name attribute
print("Student 1 Name:", student1.name)

# Accessing student2's grade attribute
print("Student 2 Grade:", student2.grade)

Output:

Student 1 Name: Ali
Student 2 Grade: 8th
  • Referencing student1.name retrieves "Ali", the specific name assigned to student1.
  • Referencing student2.grade retrieves "8th", the grade belonging specifically to student2.

5. Invoking Instance Methods

Just like attributes, instance methods are called using the dot operator (.) followed by parentheses ().

Example 1: Calling Methods on student1

# Calling display_info() to output all instance variables
student1.display_info()

# Calling is_eligible() to evaluate admission eligibility
student1.is_eligible()

Execution & Output:

Name: Ali
Age: 16
Grade: 10th
Ali is eligible for admission.
  • student1.display_info() prints all three instance variables: Ali's name, age (16), and grade (10th).
  • student1.is_eligible() inspects self.age. Because Ali's age is 16 (which is greater than 15), the if condition evaluates to True, printing that Ali is eligible for admission.

Example 2: Calling Methods on student2

# Calling both methods on student2
student2.display_info()
student2.is_eligible()

Execution & Output:

Name: Sara
Age: 14
Grade: 8th
Sara is not eligible for admission.
  • student2.display_info() displays Sara's information: Name Sara, Age 14, and Grade 8th.
  • student2.is_eligible() checks whether Sara's age is greater than 15. Because her age is 14 (less than 15), the condition fails, printing that Sara is not eligible for admission.

6. Why This Pattern Represents Good Programming Practice

Instance variables and methods are bound directly to their respective objects. This encapsulation ensures that each object's data remains completely independent and isolated. Interacting with student1 never alters or interferes with student2, maintaining clean data separation across complex software systems.

Lesson Q&A

You access an object's instance variable by writing the object name, followed by the dot operator (.), followed by the attribute name (for example, student1.name or student2.grade). When you access an attribute this way, Python retrieves the specific instance variable bound to that particular object. Accessing student1.name returns "Ali" because that was the value initialized for student1, while accessing student2.grade retrieves "8th".

You call an instance method by writing the object name, followed by a dot, the method name, and parentheses () (for example, student1.display_info() or student1.is_eligible()). The self parameter represents the specific object upon which the method was called. When student1.display_info() executes, self represents student1, allowing the method to print that specific object's name, age, and grade.

The is_eligible() instance method uses an if-else condition that checks whether self.age > 15. For student1 (Ali), the stored age is 16. Because 16 > 15 evaluates to True, the program declares that Ali is eligible for admission. For student2 (Sara), the stored age is 14. Because 14 is less than 15, the condition evaluates to False, declaring that Sara is not eligible for admission.

What children can learn

WhatsApp +92 322 421 7059

AI and Robotics Club | The 100 Mission AI & Robotics Hero Journey

Recommended self-paced course for parents & educators

ChatGPT for Kids on Udemy.

Disclosure: This page contains affiliate links. We may earn from qualifying purchases at no extra cost to you. Links are intended for parents and educators, not as marketing directed at young children.

See How Machines Learn: Age-Appropriate AI for Subang Jaya

Subang Jaya families need AI explained as data and patterns—not magic. Workshops show why models can be wrong and why personal data must never be shared with AI tools. A standard home computer is enough. Enquire support@aiandroboticsclub.com or WhatsApp +92 322 4217059.

Frequently asked questions

Is artificial intelligence easy to understand for primary and secondary students in Subang Jaya?

Yes! Our AI logic and STEM creative workshops for Subang Jaya students translate complex topics—such as computer vision, speech recognition, and machine learning models—into fun, interactive drag-and-drop projects using kid-friendly tools like mBlock.

How do these STEM workshops foster practical problem-solving skills?

By combining algorithmic thinking with hands-on maker projects, students learn how to train AI models to recognize hand gestures, classify images, and solve real-world environmental and social challenges.

Where can parents in Subang Jaya view workshop schedules and reserve a free trial?

Click the WhatsApp inquiry button on this page to receive our updated weekly timetable and claim a free 1-on-1 trial pass for your child.

Explore related learning

PuchongmBlock AI · Puchong Mont KiaraCoding · Mont Kiara CyberjayaBootcamp · Cyberjaya