0% found this document useful (0 votes)
6 views3 pages

Muhammad Abbas

This document is a lab report submitted by Muhammad Abbas for the 6th semester in the Computer Science department. It includes Python code examples demonstrating class creation, constructors, and the implementation of a rational agent for a light sensor project. The report is addressed to Sir Sikandar Azam and is dated April 28, 2025.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Muhammad Abbas

This document is a lab report submitted by Muhammad Abbas for the 6th semester in the Computer Science department. It includes Python code examples demonstrating class creation, constructors, and the implementation of a rational agent for a light sensor project. The report is addressed to Sir Sikandar Azam and is dated April 28, 2025.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name

Muhammad Abbas

Class code
BSCS-2022

Semester
6th SEMESTER “A”

Roll no
CU-2816-2022

Lab Report #
“6th”

Department
Computer Science

Submitted to
Sir Sikandar Azam

Date
28th/April /2025
1. Class in Python
class Animal:
def __init__(self, name, species):
self.name = name
self.species = species

def make_sound(self):
print(f"{self.name} makes a sound.")
dog = Animal("Buddy", "Dog")
print(dog.name)
dog.make_sound()
OUTPUT:

2. Constructor in Python
class Car:
def __init__(self, brand, model):
self.brand = brand
self.model = model
car1 = Car("Toyota", "Camry")
print(car1.brand)
OUTPUT:

3. Implementation of Rational
Agent(LightSensorProject)
class LightSensorAgent:
def __init__(self):
self.light_detected = False
def perceive_environment(self, light_value):
if light_value > 0:
self.light_detected = True
else:
self.light_detected = False

def act(self):
if self.light_detected:
print("Light detected! Moving forward.")
else:
print("No light detected. Stopping.")
agent = LightSensorAgent()
agent.perceive_environment(light_value=5)
agent.act()
agent.perceive_environment(light_value=0)
agent.act()
OUTPUT:

You might also like