Professional Documents
Culture Documents
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Impleme-
Practical Output Viva Total
Practical name Date ntation Signature
No. (5 MM) (5 MM) (20 MM)
(10 MM)
Write a python program to
1 implement Breadth First
Search Traversal?
Write a python program to
2 implement Water Jug
Problem?
Write a python program to
3 remove punctuations from the
given string?
Write a python program to sort
4 the sentence in alphabetical
order?
Write a program to implement
5 Hangman game using python.
Write a program to implement
6 Tic-Tac-Toe game using
python.
Write a python program to
remove stop words for a given
7 passage from a text file using
NLTK?
Write a python program to
implement stemming for a
8 given sentence using NLTK?
Code:
Output:
Code:
Output:
Code:
Output:
Code:
print(word)
Output:
Code:
import random
import time
if failattempt==0:
print("Fetching Your Results...")
time.sleep(5)
print("HURRAH! You Won the Game")
break
guess=input("Enter Character Here : ")
guesses+=guess
#if attempts==2:
# print("You are not doing well guessess. we providing a list of words that makes you
easy to guess. ")
#print(WORDS)
if guess not in word:
attempts-=1
print("Wrong Guess")
print(Player+","+"You have Only",+attempts,"Attempts to Win or Lose the Game")
if attempts==0:
Output:
Code:
import numpy as np
import random
from time import sleep
def create_board():
return(np.array([[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]))
def possibilities(board):
l = []
for i in range(len(board)):
for j in range(len(board)):
if board[i][j] == 0:
l.append((i, j))
return(l)
for y in range(len(board)):
if board[x, y] != player:
win = False
continue
if win == True:
return(win)
return(win)
def col_win(board, player):
for x in range(len(board)):
win = True
if win == True:
return(win)
return(win)
def evaluate(board):
winner = 0
winner = player
# Main function
def play_game():
board, winner, counter = create_board(), 0, 1
print(board)
sleep(2)
while winner == 0:
for player in [1, 2]:
board = random_place(board, player)
print("Board after " + str(counter) + " move")
Faculty Remarks & Signature
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Output:
Code:
Output:
Code:
ps = PorterStemmer()
for w in words:
print(w, " : ", ps.stem(w))
Output:
Code:
import nltk
nltk.download('tagsets')
nltk.download('punkt')
text1 = "Python is a high-level, general-purpose programming language. Its des
print(text1)
words1 = nltk.word_tokenize(text1)
print(words1)
nltk.download('averaged_perceptron_tagger')
nltk.pos_tag(words1)
nltk.help.upenn_tagset("VBZ")
Output:
Code:
Output:
Code:
import nltk
import random
nltk.download('movie_reviews')
from nltk.corpus import movie_reviews
documents = [(list(movie_reviews.words(fileid)), category)
for category in movie_reviews.categories()
for fileid in movie_reviews.fileids(category)]
random.shuffle(documents)
print(documents[1])
all_words = []
for w in movie_reviews.words():
all_words.append(w.lower())
all_words = nltk.FreqDist(all_words)
print(all_words.most_common(15))
print(all_words["stupid"])
Output:
<CategorizedPlaintextCorpusReader in '/root/nltk_data/corpora/movie_reviews'>
(['the', 'thirteenth', 'floor', ',', 'the', 'third', 'in', 'what', 'i', 'would',
'call', '"', 'the', 'reality', 'check', 'movie', 'series', '"', ',', 'is', 'very',
'similar', 'to', 'the', 'other', 'reality', 'check', 'movies', 'released', 'this',
'year', ',', 'the', 'matrix', 'and', 'existenz', '.', 'all', 'three', 'made',
'you', 'think', ',', 'made', 'you', 'wonder', 'what', 'is', 'real', ',', 'what',
'isn', "'", 't', ',', 'and', 'if', 'our', 'world', 'is', 'just', 'a', 'huge',
'game', '.', 'the', 'thirteenth', 'floor', 'doesn', "'", 't', 'reach', 'the',
'level', 'of', 'originality', ',', 'creativity', ',', 'and', 'curiosity',
'sparked', 'by', 'the', 'matrix', 'and', 'existenz', ',', 'but', 'it', 'certainly',
'gives', 'a', 'great', 'shot', 'at', 'it', '.', 'in', 'the', 'matrix', ',', 'we',
'were', 'told', 'that', 'the', 'humans', 'are', 'simply', 'a', 'virus', '.', 'in',
'existenz', ',', 'we', 'learned', 'that', 'our', 'life', 'could', 'be', 'just',
'a', 'game', '.', 'in', 'the', 'thirteenth', 'floor', ',', 'we', 'learn', 'that',
'we', 'are', 'just', 'electronic', 'devices', ',', 'living', 'under', 'another',
Faculty Remarks & Signature
KRISHNA ENGINEERING COLLEGE
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)