0% found this document useful (0 votes)
77 views8 pages

18SOECE11008 Assignment 2

The document describes three Python programs: 1. A chatbot program that holds a basic conversation with the user through a GUI. 2. A program that generates a 10x12 multiplication table and prints it. 3. A program that allows the user to view the calendar for the current month, use a calculator, or view an image based on their selection.
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)
77 views8 pages

18SOECE11008 Assignment 2

The document describes three Python programs: 1. A chatbot program that holds a basic conversation with the user through a GUI. 2. A program that generates a 10x12 multiplication table and prints it. 3. A program that allows the user to view the calendar for the current month, use a calculator, or view an image based on their selection.
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/ 8

18SOECE11008 7CEA

 Implement the following program using python


language.
1.  Create Simple Chat Conversation using Python. [ at least 10-12
Question-Answer ]

pip install tkinter

from tkinter import *

root = Tk()

root.title("Chatbot")

def send():

send = "You -> "+e.get()

txt.insert(END, "n"+send)

user = e.get().lower()

if(user == "hello"):

txt.insert(END, "n" + "Bot -> Hi")

elif(user == "hi" or user == "hii" or user == "hiiii"):

txt.insert(END, "n" + "Bot -> Hello")

elif(e.get() == "how are you"):

txt.insert(END, "n" + "Bot -> fine! and you")

elif(user == "fine" or user == "i am good" or user == "i am doing good"):

txt.insert(END, "n" + "Bot -> Great! how can I help you.")

else:

txt.insert(END, "n" + "Bot -> Sorry! I dind't got you")

e.delete(0, END)

txt = Text(root)

Devendra Dabhi Machine Learning


18SOECE11008 7CEA

txt.grid(row=0, column=0, columnspan=2)

e = Entry(root, width=100)

e.grid(row=1, column=0)

send = Button(root, text="Send", command=send).grid(row=1, column=1)

root.mainloop()

pip instal nltk


import nltk
from nltk.chat.util import Chat, reflections
reflections = {
"i am" : "you are",
"i was" : "you were",
"i" : "you",
"i'm" : "you are",
"i'd" : "you would",
"i've" : "you have",
"i'll" : "you will",
"my" : "your",
"you are" : "I am",
"you were" : "I was",
"you've" : "I have",
"you'll" : "I will",
"your" : "my",
"yours" : "mine",
"you" : "me",
"me" : "you"
}
pairs = [
[
r"my name is (.*)",

Devendra Dabhi Machine Learning


18SOECE11008 7CEA

["Hello %1, How are you today ?",]


],
[
r"hi|hey|hello",
["Hello", "Hey there",]
],
[
r"what is your name ?",
["I am a bot created by Analytics Vidhya. you can call me crazy!",]
],
[
r"how are you ?",
["I'm doing goodnHow about You ?",]
],
[
r"sorry (.*)",
["Its alright","Its OK, never mind",]
],
[
r"I am fine",
["Great to hear that, How can I help you?",]
],
[
r"i'm (.*) doing good",
["Nice to hear that","How can I help you?:)",]
],
[
r"(.*) age?",
["I'm a computer program dudenSeriously you are asking me this?",]
],

Devendra Dabhi Machine Learning


18SOECE11008 7CEA

[
r"what (.*) want ?",
["Make me an offer I can't refuse",]
],
[
r"(.*) created ?",
["Raghav created me using Python's NLTK library ","top secret ;)",]
],
[
r"(.*) (location|city) ?",
['Indore, Madhya Pradesh',]
],
[
r"how is weather in (.*)?",
["Weather in %1 is awesome like always","Too hot man here in %1","Too cold man here in
%1","Never even heard about %1"]
],
[
r"i work in (.*)?",
["%1 is an Amazing company, I have heard about it. But they are in huge loss these days.",]
],
[
r"(.*)raining in (.*)",
["No rain since last week here in %2","Damn its raining too much here in %2"]
],
[
r"how (.*) health(.*)",
["I'm a computer program, so I'm always healthy ",]
],
[
r"(.*) (sports|game) ?",

Devendra Dabhi Machine Learning


18SOECE11008 7CEA

["I'm a very big fan of Football",]


],
[
r"who (.*) sportsperson ?",
["Messy","Ronaldo","Roony"]
],
[
r"who (.*) (moviestar|actor)?",
["Brad Pitt"]
],
[
r"i am looking for online guides and courses to learn data science, can you suggest?",
["Crazy_Tech has many great articles with each step explanation along with code, you can
explore"]
],
[
r"quit",
["BBye take care. See you soon :) ","It was nice talking to you. See you soon :)"]
],
]

2.  Create Multiplication Table of 10*12 Matrix.

#include<stdio.h>

#include<conio.h>

int main()

int i, j, product;

Devendra Dabhi Machine Learning


18SOECE11008 7CEA

clrscr();

/* Generating Multiplication Table */

for(i=1;i<=10;i++)

for(j=1;j<=10;j++)

product = i*j;

printf("%d x %d = %d\t", i, j, product);

printf("\n");

getch();

return(0);

3.  Based on the user's choice to show calendar of current month,


calculator, and image from the drive. 

function createEvent() {

var calendarId = 'primary';

var start = getRelativeDate(1, 12);

var end = getRelativeDate(1, 13);

var event = {

summary: 'Lunch Meeting',

location: 'The Deli',

Devendra Dabhi Machine Learning


18SOECE11008 7CEA

description: 'To discuss our plans for the presentation next week.',

start: {

dateTime: start.toISOString()

},

end: {

dateTime: end.toISOString()

},

attendees: [

{email: '[email protected]'},

{email: '[email protected]'}

],

// Red background. Use Calendar.Colors.get() for the full list.

colorId: 11

};

event = Calendar.Events.insert(event, calendarId);

Logger.log('Event ID: ' + event.id);

/**

* Helper function to get a new Date object relative to the current date.

* @param {number} daysOffset The number of days in the future for the new date.

* @param {number} hour The hour of the day for the new date, in the time zone

* of the script.

Devendra Dabhi Machine Learning


18SOECE11008 7CEA

* @return {Date} The new date.

*/

function getRelativeDate(daysOffset, hour) {

var date = new Date();

date.setDate(date.getDate() + daysOffset);

date.setHours(hour);

date.setMinutes(0);

date.setSeconds(0);

date.setMilliseconds(0);

return date;

Devendra Dabhi Machine Learning

You might also like