100% found this document useful (1 vote)
159 views

AI - Lab#08 - Task - Solution

The document contains coding for two tasks in an AI and robotics lab. Task 1 involves coding to print a multiplication table for a given number within a specified range. Task 2 involves coding to collect personal information from a user such as name, city, course details, and print this information in a structured format using frames and instances in a knowledge base.

Uploaded by

Babar Khan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
159 views

AI - Lab#08 - Task - Solution

The document contains coding for two tasks in an AI and robotics lab. Task 1 involves coding to print a multiplication table for a given number within a specified range. Task 2 involves coding to collect personal information from a user such as name, city, course details, and print this information in a structured format using frames and instances in a knowledge base.

Uploaded by

Babar Khan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

CE-401 ARTIFICIAL INTELLIGENCE & ROBOTICS

LAB # 08
TASK # 01

CODING:
question number
Please enter a number;
input integer ; % only accepts integers
because I will print a table of that number for you.
question range_s
Please enter the range (Start) for the table;
input integer ; % only accepts integers
because Table Starting RANGE.
question range_e
Please enter the range (End) for the table;
input integer ; % only accepts integers
because Table Ending RANGE.
action print_table ;
do ask number
and do ask range_s
and do ask range_e
and do for N from range_s to range_e
do write(' ') and write(number) and write(' x ')
and do write(N) and do write(' = ') and do write(N * number) and nl
end for.
TASK # 02
CODING:
question your_name
Please enter your name ;
input name ;
because I would like to call you personally.
question your_city
Please enter your city ;
input name ;
because I would like to know where do you live.
question your_country
Please enter your country ;
input name ;
because I would like to know where are you from.
question your_inst
Please enter your institution ;
input name ;
because I would like to know where do you study.
question your_cname
Please enter your course title ;
input name ;
because I would like to know what do you study.
question your_ccode
Please enter your course code ;
input name ;
because I would like to know the course code.
question your_teacher
Please enter your teacher name ;
input name ;
because I would like to know what do you study.
question your_dept
Please enter your department name ;
input name ;
because I would like to know what do you study.
frame base ;
default name is your_name and
default city is your_city and
default country is your_country and
default inst is your_inst and
default cname is your_cname.
instance derived1 is a base ;
ccode is your_ccode and
teacher is your_teacher.
instance derived2 is a base ;
dept is your_dept.
action exec_prog ;
do ask your_name and
do ask your_city and
do ask your_country and
do ask your_inst and
do ask your_cname and
do ask your_ccode and
do ask your_teacher and
do ask your_dept and
do write (' base') and nl and
do write('Name: ') and write( base`s name ) and nl and
do write('City: ') and write( base`s city ) and nl and
do write('Country: ') and write( base`s country ) and nl and
do write('Institution: ') and write( base`s inst ) and nl and
do write('Course Name: ') and write( base`s cname ) and nl and
do for every S is an instance of base
do write (' ') and write(S) and nl and
do write('Course Code: ') and write( S`s ccode ) and nl and
do write('Teacher Name: ') and write( S`s teacher ) and nl and
do write('Department: ') and write( S`s dept ) and nl
end for .

You might also like