Professional Documents
Culture Documents
19bcs2979 Aiml Lab All Worksheet
19bcs2979 Aiml Lab All Worksheet
Branch: BE CSE Section/Group : A
EXPERIMENT NO 1
3. S/W Requirement :
if jug1 == 0:
if jug2 == max_vol:
visited = set()
q = deque()
q.append((0, 0))
while q:
curr = q.popleft()
return curr
if curr in visited:
continue
visited.add(curr)
return None
max_vol1 = 4
max_vol2 = 3
goal = 2
5. Result/Output/Writing Summary:
Evaluation Grid (To be filled by the faculty):
1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)
3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained:
Student Name: Pravesh Azan UID: 19BCS2979
Branch: BE CSE Section/Group : A
EXPERIMENT NO 2
3. S/W Requirement :
def print_board():
for row in board:
print("|".join(row))
def check_win(player):
# check rows
for row in board:
if row == [player, player, player]:
return True
# check columns
for i in range(3):
if board[0][i] == player and board[1][i] == player and board[2][i] ==
player:
return True
# check diagonals
if board[0][0] == player and board[1][1] == player and board[2][2] ==
player:
return True
if board[0][2] == player and board[1][1] == player and board[2][0] ==
player:
return True
return False
def play_game():
player = "X"
while True:
print_board()
print(f"{player}'s turn. Which row?")
row = int(input())
print(f"{player}'s turn. Which column?")
col = int(input())
if board[row][col] == " ":
board[row][col] = player
if check_win(player):
print_board()
print(f"{player} wins!")
break
player = "O" if player == "X" else "X"
else:
print("That space is already occupied. Try again.")
play_game()
5. Result/Output/Writing Summary:
Evaluation Grid (To be filled by the faculty):
1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)
3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained:
Student Name: Pravesh Azan UID: 19BCS2979
Branch: BE CSE Section/Group : A
EXPERIMENT NO 3
3. S/W Requirement :
print(bfs(graph, "A"))
5. Result/Output/Writing Summary:
Evaluation Grid (To be filled by the faculty):
1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)
3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained:
Student Name: Pravesh Azan UID: 19BCS2979
Branch: BE CSE Section/Group : A
EXPERIMENT NO 4
3. S/W Requirement :
print(dfs(graph, "A"))
5. Result/Output/Writing Summary:
Evaluation Grid (To be filled by the faculty):
1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)
3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained:
Student Name: Pravesh Azan UID: 19BCS2979
Branch: BE CSE Section/Group : A
EXPERIMENT NO 5
3. S/W Requirement :
def solve_n_queens(n):
def is_valid(board, row, col):
# Check if a queen can be placed on board[row][col]
# Check column
for i in range(row):
if board[i] == col or \
abs(board[i] - col) == abs(i - row):
return False
return True
result = []
backtrack([-1] * n, 0)
return result
print(solve_n_queens(4))
5. Result/Output/Writing Summary:
Evaluation Grid (To be filled by the faculty):
1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)
3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained:
Student Name: Pravesh Azan UID: 19BCS2979
Branch: BE CSE Section/Group : A
EXPERIMENT NO 6
3. S/W Requirement :
import random
responses = {
"hi": ["Hello!", "Hi there!", "Hey!"],
"how are you": ["I'm good, thank you!", "I'm doing well, thanks for
asking!", "I'm just a computer program, but I'm functioning well!"],
"bye": ["Goodbye!", "See you later!", "Bye!"]
}
def chatbot():
while True:
user_input = input("You: ").lower()
if user_input in responses:
print("Chatbot: " + random.choice(responses[user_input]))
elif user_input == "bye":
print("Chatbot: " + random.choice(responses["bye"]))
break
else:
print("Chatbot: I'm sorry, I didn't understand what you said.")
chatbot()
5. Result/Output/Writing Summary:
Evaluation Grid (To be filled by the faculty):
1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)
3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained:
Student Name: Pravesh Azan UID: 19BCS2979
Branch: BE CSE Section/Group : A
EXPERIMENT NO 7
Write a python program to for text classification for the give sentence
2. Task to be done/ Which logistics used:
To implement a for text classification for the give sentence using python
program
3. S/W Requirement :
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
# example sentence
sentence = "This is a positive sentence."
# create a dataframe with the sentence and its label
df = pd.DataFrame({'sentence': [sentence], 'label': ['positive']})
5. Result/Output/Writing Summary:
Evaluation Grid (To be filled by the faculty):
1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)
3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained:
Student Name: Pravesh Azan UID: 19BCS2979
Branch: BE CSE Section/Group : A
EXPERIMENT NO 8
3. S/W Requirement :
parent(john, jim).
parent(jim, jake).
parent(jake, jane).
parent(jane, jack).
parent(jane, jill).
parent(jim, jessica).
% rule to determine grandparents
grandparent(GP, GC) :- parent(GP, P), parent(P, GC).
5. Result/Output/Writing Summary:
?- parent(john,X).
this will return “jim”
?- grandparent(X,jack).
this will return “john”
?- sibling(jake,X).
this will returrn “jessica”
1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)
3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained:
Student Name: Pravesh Azan UID: 19BCS2979
Branch: BE CSE Section/Group : A
EXPERIMENT NO 9
3. S/W Requirement :
% facts
likes(jim, pizza).
likes(jim, ice_cream).
likes(jake, chocolate).
likes(jake, pizza).
% query
?- same_taste(jim, jake).
5. Result/Output/Writing Summary:
Evaluation Grid (To be filled by the faculty):
1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)
3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained:
Student Name: Pravesh Azan UID: 19BCS2979
Branch: BE CSE Section/Group : A
EXPERIMENT NO 10
3. S/W Requirement :
# training data
X = [[0,0], [0,1], [1,0], [1,1]]
y = [0, 1, 1, 1]
# calculate accuracy
acc = accuracy_score(test_labels, predictions)
print("Accuracy:", acc)
5. Result/Output/Writing Summary:
Evaluation Grid (To be filled by the faculty):
1. Understanding and 12
knowledge about the
procedure and the apparatus
2. Theoretical overview of the 8
experiment. (Viva/Voce)
3. Completion of worksheet 10
with learning outcomes
along with cleanliness and
discipline.
Signature of Faculty (with Total Marks 30
Date): Obtained: