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

AI Lab 1 17102024 121720pm

The document outlines a lab journal for a Computer Science course at Bahria University, focusing on artificial intelligence principles and Python programming. It includes three main tasks: understanding Python indentation and debugging, creating an advanced calculator, and developing a unit conversion calculator, each with specific objectives and requirements. Students are instructed to submit their Python code, explanations, and visualizations as part of their evaluation.

Uploaded by

M T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

AI Lab 1 17102024 121720pm

The document outlines a lab journal for a Computer Science course at Bahria University, focusing on artificial intelligence principles and Python programming. It includes three main tasks: understanding Python indentation and debugging, creating an advanced calculator, and developing a unit conversion calculator, each with specific objectives and requirements. Students are instructed to submit their Python code, explanations, and visualizations as part of their evaluation.

Uploaded by

M T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Artificial Intelligence Lab

BSCS 6-A

Department of Computer Science


Bahria University, Lahore Campus

Lab Journal: [1]


Name: _____________________
Roll No: ___________________
Evaluation of CLO Question Marks Obtained
Number Marks

CLO2: Apply basic principles of AI in solutions that require 1 10


problem-solving, inference, perception, knowledge representation,
and learning

Total Marks 10

Objective(s):
To Understand about:
Task 1: Explore Python indentation, debug errors, and understand how indentation affects program behavior.
Task 2: Create an advanced calculator with extended mathematical functionalities and robust error handling.
Task 3: Implement a comprehensive unit conversion calculator with support for advanced conversions and user-
defined rates.

Lab Tasks:

Task 1: Understanding Indentation and Debugging in Python

Objective: To explore the importance of proper indentation in Python and understand how to debug common
indentation errors.

Question:

1. Open IDLE and write the following program to calculate the sum of two numbers.
python
Copy code
def add_numbers(a, b):
print("The sum is:", a + b)
add_numbers(10, 20)

oExperiment with different indentations for the print and add_numbers lines.
oMake a note of errors that occur due to incorrect indentation and correct them.
oModify the program to include another function for subtraction and observe how indentation
affects nested functions.
2. Extend the program to:
o Handle errors for incorrect inputs (e.g., entering strings instead of numbers).
o Add a try-except block to catch and display error messages.

Solution [copy your code solution and output below, adjust the font accordingly]

Task 2: Advanced Calculator with Extended Functionality

Objective: To create a fully functional calculator with advanced operations and robust error handling.

Question:

1. Write a Python program to implement a calculator with the following features:


o A Menu function to display options: addition, subtraction, multiplication, division, factorial,
xyx^yxy, logarithm, and natural logarithm.
o Separate functions for each operation with proper error handling (e.g., division by zero, invalid
inputs).
o The program should allow the user to select operations repeatedly until they choose to quit.
2. Bonus Task:
o Extend the calculator to include:
 Square Root Calculation
 Trigonometric Functions (sin, cos, tan)
 Complex Number Arithmetic
o Display appropriate messages for invalid inputs and implement validations for each operation.

Solution [copy your code solution and output below, adjust the font accordingly]
Task 3: Advanced Unit Conversion Calculator

Objective: To develop a versatile unit conversion calculator with support for advanced conversions and robust
error handling.

Question:

1. Write a Python program to implement a unit conversion calculator with the following features:
o A Menu function to display options:
 Meter to kilometer
 Kilometer to meter
 Centimeter to meter
 Centimeter to millimeter
 Additional options:
 Fahrenheit to Celsius
 Celsius to Fahrenheit
 Pounds to kilograms
 Kilograms to pounds
o Separate functions for each conversion.
2. Additional Tasks:
o Include a feature to allow users to input custom conversion rates for units not listed in the menu.
o Implement error handling for invalid input values (e.g., negative distances or temperatures outside
a realistic range).
3. The program should loop continuously, allowing multiple conversions until the user chooses to quit.

Solution [copy your code solution and output below, adjust the font accordingly]

Submission Instructions: Submit your Python code and explanations. Ensure to provide screenshots of all
visualizations along with your answers.

You might also like