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

AI Lab Manual Solutions Part1

The document is a lab manual for an Artificial Intelligence course, focusing on Python programming and data types. It includes exercises with code snippets and explanations for basic programming concepts such as printing, arithmetic operations, type casting, logical operators, and temperature conversion. Each lab section provides practical coding examples to reinforce learning.

Uploaded by

kumarsumair857
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)
28 views3 pages

AI Lab Manual Solutions Part1

The document is a lab manual for an Artificial Intelligence course, focusing on Python programming and data types. It includes exercises with code snippets and explanations for basic programming concepts such as printing, arithmetic operations, type casting, logical operators, and temperature conversion. Each lab section provides practical coding examples to reinforce learning.

Uploaded by

kumarsumair857
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 Manual

Solutions
Lab No. 1: Introduction to Python Programming
1. Exercise 1:

Code:

print("Hello World")

Explanation:

Prints Hello World to the screen.

2. Exercise 2:

Code:

a=4
b=5
print("Sum:", a + b)

Explanation:

Adds two numbers and prints the result.

3. Exercise 3:

Code:

x = 42
print("Type of x:", type(x))

Explanation:

Displays the type of variable x.

4. Exercise 4:

Code:
x = "100"
y = int(x)
print("Type after casting:", type(y))

Explanation:

Casts a string to an integer.

5. Exercise 5:

Code:

a = True
b = False
print("Logical AND:", a and b)

Explanation:

Demonstrates logical AND operator.

Lab No. 2: Data Types and Conditional Statements


6. Exercise 1:

Code:

import math
x = 16
print("Square root:", math.sqrt(x))

Explanation:

Finds square root of a number.

7. Exercise 2:

Code:

x=2
y=3
print("Linear equation result:", 2*x + 3*y)

Explanation:

Performs a linear equation.


8. Exercise 3:

Code:

print("Calculator:")
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Sum:", a+b)
print("Difference:", a-b)
print("Product:", a*b)
print("Quotient:", a/b)

Explanation:

Basic calculator program.

9. Exercise 4:

Code:

celsius = 37
fahrenheit = (celsius * 9/5) + 32
print("Celsius to Fahrenheit:", fahrenheit)

Explanation:

Temperature conversion.

10. Exercise 5:

Code:

for i in range(1500, 2701):


if i % 7 == 0 and i % 5 == 0:
print(i)

Explanation:

Finds numbers divisible by 7 and multiple of 5 between 1500 and 2700.

You might also like