Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

AMBEDKAR INSTITUTE OF TECHNOLOGY

Shakarpur, Near Madhuban, Delhi -110092

Session : 2020-2021
Minor Project

Department – ITES&M
Semester – 5th Semester (3rd Year)

Submitted To: Submitted By:


Dr. Dipankar Mishra Abhishek Karn (1802111002)
(H.O.D) Ankit kr. Srivastava (1802111005)
CONTENT

*ACKNOWLEDGEMENT

*DECLARATION

*TOPIC

*ADVANTAGES

*Description about all function used

*Source code

*References
ACKNOWLEDGEMENT

I have tried to put all my efforts in this project. However,


this project would not have
been possible without fewpeople who helped me to
complete this project.
I amhighly obliged to our Incharge “Dr. Dipankar Mishra”
for his guidance and support. He also provided all
necessary
information for the completion of project.
I would also like to thank my teachers who helped me and
guided me at every stage. I can’t say thank you enough for
their continuous support and help.
I would also like to express my gratitude towards my
friends also who willingly helped me out according to
their skills.
DECLARATION
I hereby declared that
“artificial intelligence(basic)” is an original project
done by us under the guidance of teachers and incharge.
The project is being submitted as a Minor Project in 5th
semester.
The source code is originally mine and it is not being
submitted by any other student of the class.
Abhishek karn (1802111002)
Ankit kr. Srivastava (1802111005)
Introduction
It all thing related to our requirement. we as student
Always think that all the things we want to do become
easier.
In current era, we see such a thing like Siri,
Alexa, Google assistant that help us to make our life
lightly easier than earlier. Like play music, some
search like “search MS dhoni on Wikipedia.”, what is
owner name etc.
As student we are new in this field, we just started
all the things with simple thing like how to code to
that machine could speak, we search about it, find
related content on it and them implement it.
Like building a house, we put blocks so related to it
we make this project with this approach which is
technically top down approach, we find every thing
We find in every artificial bot and try to put it in our
project.
Artificial Intelligence (AI) is a way to make machines think and behave intelligently.
These machines are controlled by software inside them, so AI has a lot to do with
intelligent software programs that control these machines. It is a science of finding
theories and methodologies that can help machines understand the world and
accordingly react to situations in the same way that humans do.
If we look closely at how the field of AI has emerged over the last couple of decades,
you will see that different researchers tend to focus on different concepts to define
AI. In the modern world, AI is used across many verticals in many different forms. We
want the machines to sense, reason, think, and act. We want our machines to be
rational too.
AI is closely related to the study of human brain. Researchers believe that AI can be
accomplished by understanding how the human brain works. By mimicking the way
the human brain learns, thinks, and takes action, we can build a machine that can do
the same. This can be used as a platform to develop intelligent systems that are
capable of learning.

Branches of artificial intelligence

It is important to understand the various fields of study within AI so that we can


choose the right framework to solve a given real-world problem. Here's a list of
topics that are dominant:
o Machine learning and pattern recognition: This is perhaps the most
popular form of AI out there. We design and develop software that can
learn from data. Based on these learning models, we perform
predictions on unknown data. One of the main constraints here is that
these programs are limited to the power of the data. If the dataset is
small, then the learning models would be limited as well.

Logic-based AI: Mathematical logic is used to execute computer programs in


logic-based AI. A program written in logic-based AI is basically a set of
statements in logical form that express facts and rules about a particular
problem domain. This is used extensively in pattern matching, language
parsing, semantic analysis, and so on.
o Search: The Search techniques are used extensively in AI programs.
These programs examine a large number of possibilities and then pick
the most optimal path. For example, this is used a lot in strategy games
such as Chess, networking, resource allocation, scheduling, and so on.

o Knowledge representation: The facts about the world around us need to


be represented in some way for a system to make sense of them. The
languages of languages of mathematical logic are frequently used here.

o Planning: This field deals with optimal planning that gives us maximum
returns with minimal costs. These software programs start with facts
about the particular situation and a statement of a goal. These programs
are also aware of the facts of the world, so that they know what the
rules are. From this information, they generate the most optimal plan to
achieve the goal.

o Heuristics: A heuristic is a technique used to solve a given problem


that's practical and useful in solving the problem in the short term, but
not guaranteed to be optimal. This is more like an educated guess on
what approach we should take to solve a problem. In AI, we frequently
encounter situations where we cannot check every single possibility to
pick the best option. So we need to use heuristics to achieve the goal.
They are used extensively in AI in fields such as robotics, search
engines, and so on.

Computer Vision: These are the systems that deal with visual data such as
images and videos. These systems understand the content and extract
insights based on the use case. For example, Google uses reverse image
search to search for visually similar images across the Web.
Natural Language Processing: This field deals with understanding text. We
can interact with a machine by typing natural language sentences. Search
engines use this extensively to deliver the right search results.

Speech Recognition: These systems are capable of hearing and


understanding spoken words. For example, there are intelligent personal
assistants on our smartphones that can understand what we are saying and
give relevant information or perform an action based on that.

Expert Systems: These systems use AI techniques to provide advice or make


decisions. They usually use databases of expert knowledge areas such as
finance, medicine, marketing, and so on to give advice about what to do next.
Let's see what an expert system looks like and how it interacts with the
user.

• Games: AI is used extensively in the gaming industry. It is used to design


intelligent agents that can compete with humans. For example, AlphaGo is a
computer program that can play the strategy game Go. It is also used in
designing many other types of games where we expect the computer to
behave intelligently.

• Robotics: Robotic systems actually combine many concepts in AI. These


systems are able to perform many different tasks. Depending on the situation,
robots have sensors and actuators that can-do different things. These sensors
can see things in front of them and measure the temperature, heat,
movements, and so on. They have processors on board that compute various
things in real time. They are also capable of adapting to the new environments.
Python is one of the most popular programming languages used by developers today.
Guido Van Rossum created it in 1991 and ever since its inception has been one of the
most widely used languages along with C++, Java, etc.

In our endeavour to identify what is the best programming language for AI and neural
network, Python has taken a big lead.

Python and Artificial Intelligence(AI) - How do they relate?


Python is one of the most popular programming languages used by developers today.
Guido Van Rossum created it in 1991 and ever since its inception has been one of the
most widely used languages along with C++, Java, etc.

In our endeavour to identify what is the best programming language for AI and neural
network, Python has taken a big lead. Let us look at why Artificial Intelligence with
Python is one of the best ideas under the sun.

Features and Advantages of Python


Python is an Interpreted language which in lay man’s terms means that it does not
need to be compiled into machine language instruction before execution and can be
used by the developer directly to run the program. This makes it comprehensive
enough for the language to be interpreted by an emulator or a virtual machine on top
of the native machine language which is what the hardware understands.

It is a High-Level Programming language and can be used for complicated scenarios.


High-level languages deal with variables, arrays, objects, complex arithmetic or
Boolean expressions, and other abstract computer science concepts to make it more
comprehensive thereby exponentially increasing its usability.

Python is also a General-purpose programming language which means it can be used


across domains and technologies.

Python also features dynamic type system and automatic memory management
supporting a wide variety of programming paradigms including object-oriented,
imperative, functional and procedural to name a few.
Python is available for all Operating Systems and also has an open-source offering
titled CPython which is garnering widespread popularity as well.

Let us now look as to how using Python for Artificial Inelegance gives us an edge over
other popular programming languages

AI and Python: Why?


The obvious question that we need to encounter at this point is why we should
choose Python for AI over others.

Python offers the least code among others and is in fact 1/5 the number compared to
other OOP languages. No wonder it is one of the most popular in the market today.

• Python has Prebuilt Libraries like Numpy for scientific computation, Scipy for
advanced computing and Pybrain for machine learning (Python Machine
Learning) making it one of the best languages For AI.
• Python developers around the world provide comprehensive support and
assistance via forums and tutorials making the job of the coder easier than any
other popular languages.
• Python is platform Independent and is hence one of the most flexible and
popular choiceS for use across different platforms and technologies with the
least tweaks in basic coding.
• Python is the most flexible of all others with options to choose between OOPs
approach and scripting. You can also use IDE itself to check for most codes and
is a boon for developers struggling with different algorithms.

Decoding Python alongside AI


Python along with packages like NumPy, scikit-learn, iPython Notebook, and
matplotlib form the basis to start your AI project.

NumPy is used as a container for generic data comprising of an N-dimensional array


object, tools for integrating C/C++ code, Fourier transform, random number
capabilities, and other functions.

Another useful library is pandas, an open source library that provides users with
easy-to-use data structures and analytic tools for Python.
Matplotlib is another service which is a 2D plotting library creating publication quality
figures. You can use matplotlib to up to 6 graphical users interface toolkits, web
application servers, and Python scripts.

Your next step will be to explore k-means clustering and also gather knowledge
about decision trees, continuous numeric prediction, logistic regression, etc.

Some of the most commonly used Python AI libraries are AIMA, pyDatalog, SimpleAI,
EasyAi, etc. There are also Python libraries for machine learning like PyBrain, MDP,
scikit, PyML.

Let us look a little more in detail about the various Python libraries in AI and why this
programming language is used for AI

Python vs. C++ for AI

• Python is a more popular language over C++ for AI and leads with a 57% vote
among developers. That is because Python is easy to learn and implement.
With its many libraries, they can also be used for data analysis.
• Performance wise C++ outperforms Python. This is because C++ has the
advantage of being a statically typed language and hence there are no typing
errors during runtime. C++ also creates more compact and faster runtime
code.
• Python is a dynamic (as opposed to static) language and reduces complexity
when it comes to collaborating meaning you can implement functionality with
less code. Unlike C++, where all significant compilers tend to do specific
optimisation and can be platform specific, Python code can be run on pretty
much any platform without wasting time on specific configurations.
• With the rise of GPU-accelerated computing offering capabilities for
parallelism which has led to the creation of libraries such as CUDA Python and
cuDNN, Python has the edge over C++. This means is that more and more of
the actual computing for machine learning workloads is being offloaded to
GPUs – and the result is that any performance advantage that C++ may have is
becoming increasingly irrelevant.
• Python wins over C++ regarding simplicity of code, especially amongst new
developers. C++ being a lower-level language requires more experience and
skill to master.
• Python’s simple syntax also allows for a more natural and intuitive ETL
(Extract, Transform, Load) process, and means that it is faster for development
when compared to C++, allowing developers to test machine learning
algorithms without having to implement them quickly.

Between C++ and Python, the latter has more edge and is more suitable for AI. With
its simple syntax and readability promoting the rapid testing of complex machine
learning algorithms and a thriving community bolstered by collaborative tools like
Jupyter Notebooks and Google Colab, Python wins the crown.
Main function and modules

• Pyttsx3:
pyttsx3 is a text-to-speech conversion library in Python. Unlike alternative
libraries, it works offline and is compatible with both Python 2 and 3. An
application invokes the pyttsx3. init() factory function to get a reference to
a pyttsx3. Engine instance.

• Date and time:


It is used to tell about the current time and date.

# function for time


def time():
time = datetime.datetime.now().strftime("%I:%M:%S")
speak("the current time is")
speak(time)

# function for date


def date():
year = datetime.datetime.now().year
month = datetime.datetime.now().month
day = datetime.datetime.now().day
speak(day)
speak(month)
speak(year)

• Speech recognition
In speech recognition module of python, we use pyaudio which is required if
and only if we want to use microphone input (microphone). PyAudio version
0.2.11+ is required, as earlier versions have known memory management bugs
when recording from microphones in certain situations. If not installed,
everything in the library will still work, except attempting to instantiate a
microphone object will raise an Attribute ERROR. After it we initialize the
recognizer function of module.
# taking command function from user
try:
def takecommand():
r = sr.Recognizer()

with sr.Microphone() as source:


print("listing")
r.pause_threshold = 3
audio = r.listen(source)

try:
print("recognizing")
try:
query = r.recognize_google(audio)
except Exception:
speak("could you say it again")

print(query)
return query

except Exception as e:
print(e)

• Wikipedia
Wikipedia is a Python library that makes it easy to access and parse data
from Wikipedia. Search Wikipedia, get article summaries, get data like links
and images from a page.
query = query.replace("WIKIPEDIA","")
result = wk.summary(query, sentences=3)
print(result)
speak(result)
• OS module
The OS module in python provides functions for interacting with the operating
system. OS, comes under Python's standard utility modules.
This module provides a portable way of using operating system dependent
functionality. The *os* and *os. path* modules include many functions to
interact with the file system.
elif 'logout' in query:
os.system("shutdown -1")

elif 'shutdown' in query:


os.system("shutdown /s /t 1")

elif 'restart' in query:


os.system("shutdown /r /t 1")

• Pyjokes
One-line jokes for programmers (jokes as a service).
# function for jokes
def jokes():
speak(pj.get_jokes(language="en",category="neutral"))

• Psutil
psutil (python system and process utilities) is a cross-platform library for
retrieving information on running processes and system utilization (CPU,
memory, disks, network, sensors) in Python. It is useful mainly for system
monitoring, profiling, limiting process resources and the management of
running processes
# function for cpu status
def cpu():
usage = str(pu.cpu_percent())
speak("cpu is at" + usage)
battery =pu.sensors_battery()
speak("battery is at")
speak(battery)
• Play music function
Using os module I use it to play music, first define the path of music path.
Then call the listdir function and startfile function to run it.
elif 'play music' in query:
try:
songs_dir ='G:\\Music\\phone'
songs = os.listdir(songs_dir)
os.startfile(os.path.join(songs_dir,songs[0]))
except Exception:
speak(Exception)
print(Exception)

• Pyautogui
PyAutoGUI lets your Python scripts control the mouse and keyboard to
automate interactions with other applications. The API is designed to be as
simple. PyAutoGUI works on Windows, macOS, and Linux, and runs on Python 2
and 3.

elif 'screenshot' in query:


try:
image =pg.screenshot()
image.save("c:\\users\\hp\\maith ai project\\screenshot")
speak("screenshot taken")
except Exception :
print(Exception)
speak(Exception)

• Wishing function
Using this function, it wishes good morning, noon, after noon, evening and night
with the use of date time module of python.

# function for wishing


def wish():
hour = datetime.datetime.now().hour

if hour > 5 and hour < 12:


speak("good morning sir")
elif hour == 12:
speak("good noon sir")
elif hour > 12 and hour < 18:
speak("good afternoon sir")
elif hour > 18 and hour < 20:
speak("good evening sir")
else:
speak("good night sir")

• Login function
Here we login into the program. using authorised email id and password we
can login into it. After getting the email id and password it calls administration
modules admin function.
# login area ==============#
tprint("welcome")
speak("welcome")
speak("who are you?? old user or new user.")
print("1. new user ")
print("2. old user")
k1=takecommand().lower()
if "old" in k1:
speak('please enter your email')
email = input("enter your email")
str(email)
speak('enter your password')
password= input("enter your password")
str(password)
z=adminstration.admin(email,password)
str(z)

• administration module
we use administration module to login in program with sql connectivity.
Using this it will verify from getting the data through login area then check it in
sql database. Here I make a database name Jarvis and table password. using
select command the administration will check the login criteria is right or not
if inputs are correct then it will return the name of the user other wise it will
close the program.
def admin(email,password):

server = pymysql.connect( host="localhost", user="root",password="Asrmath1053


#")
a = server.cursor()
sql="USE jarvis;"
a.execute(sql)
try:

a.execute('SELECT name FROM password WHERE email = %s AND password = %s',


(email, password,))
k=a.fetchall()

except Exception as e:
print(e)

return k

• pymysql
it is module of python to connect program to database.
First import the module, then connect it using connect function of pymysql
module using database host name, password. Call the cursor to initialize the
operation, then using execute function of module connect.
server = pymysql.connect( host="localhost", user="root",password="Asrmath1053#")
a = server.cursor()

sql="USE jarvis;"
a.execute(sql)

• Description about its own


Using the statements like how are you , your important imports , do you
remember anything etc.

• News
By using this we get news updates.
def pasrefeed():
f=feedparser.parse("https://feeds.bbci.co.uk/news/rss.xml")
for newsitem in f['items']:
notification.notify(title=newsitem['title'],message=str(newsitem['summary
']),timeout=10)
time.sleep(10)
• Art
Art package is used to print decorative arts on the terminal as well as to save in
file and a word can be represented by” | “and can be saved in a file

• Smtp
The smtplib module defines an SMTP client session object that can be used to
send mail to any Internet machine with an SMTP or ESMTP listener daemon. ...
An SMTP instance encapsulates an SMTP connection. It has methods that
support a full repertoire of SMTP and ESMTP operations.
def sendmail(to,content):
try:
server=sb.SMTP_SSL('smtp.gmail.com',587)
server.ehlo()
server.starttls()
server.login('maith.artifi@gmail.com','asrmath1053')
server.sendmail('maith.artifi@gmail.com',to,content)
server.close()
except:
print("something wents wrong....")

• Selenium
Python language bindings for Selenium WebDriver. The selenium package is
used to automate web browser interaction from Python. Several
browsers/drivers are supported (Firefox, Chrome, Internet Explorer), as well
as the Remote protocol.
elif 'open chrome' in query:
driver = webdriver.Chrome("C:\\Program Files (x86)\\Google\\C
hrome\\Application\\chrome.exe")
import pyttsx3
import speech_recognition as sr
abc= pyttsx3.init()

def speak(audio):
abc.say(audio)
abc.runAndWait()

try:
def takecommand():
r = sr.Recognizer()

with sr.Microphone() as source:


print("listing")
r.pause_threshold = 3
audio = r.listen(source)

try:
print("recognizing")
try:
query = r.recognize_google(audio)
except Exception:
speak("could you say it again")

print(query)
return query

except Exception as e:
print(e)

except Exception as k:
speak(k)

# minor project created by ankit kumar srivastava (1802111005) and


Abhishek karn (1802111002)
# submitted to DR. Dipankar Mishra, ITES&m 5TH sem,
ambedkar institute of technology
# mandawali, new Delhi

#======================================#
#-----------imports--------------------#
#======================================#

import pyttsx3
import datetime
import speech_recognition as sr
import wikipedia as wk
import smtplib as sb,ssl
import webbrowser as wb
import os
from selenium import webdriver
import pyautogui as pg
import psutil as pu
import pyjokes as pj
import pymysql
import adminstration
import sqlai
import feedparser
from plyer import notification
import time
from art import *
# initialization of pyttsx3 module
abc = pyttsx3.init()

# function for sending email


def sendmail(to,content):
try:
server=sb.SMTP_SSL('smtp.gmail.com',587)
server.ehlo()
server.starttls()
server.login('maith.artifi@gmail.com','asrmath1053')
server.sendmail('maith.artifi@gmail.com',to,content)
server.close()
except:
print("something wents wrong....")

# function for jokes


def jokes():
speak(pj.get_jokes(language="en",category="neutral"))

# function for speaking something


def speak(audio):
abc.say(audio)
abc.runAndWait()

# function for wishing


def wish():
hour = datetime.datetime.now().hour

if hour > 5 and hour < 12:


speak("good morning sir")
elif hour == 12:
speak("good noon sir")
elif hour > 12 and hour < 18:
speak("good afternoon sir")
elif hour > 18 and hour < 20:
speak("good evening sir")
else:
speak("good night sir")

# function for time


def time1():
time = datetime.datetime.now().strftime("%I:%M:%S")
speak("the current time is")
speak(time)

# function for date


def date():
year = datetime.datetime.now().year
month = datetime.datetime.now().month
day = datetime.datetime.now().day
speak(day)
speak(month)
speak(year)

# function for cpu status


def cpu():
usage = str(pu.cpu_percent())
speak("cpu is at" + usage)
battery =pu.sensors_battery()
speak("battery is at")
speak(battery)

def pasrefeed():
f=feedparser.parse("https://feeds.bbci.co.uk/news/rss.xml")
for newsitem in f['items']:
notification.notify(title=newsitem['title'],message=str(newsitem['summary']),timeo
ut=30)
time.sleep(30)

def reset():

# password reseting area


speak("your entered password is wrong")
speak("do you want to change your password")
sri=takecommand().lower()

if "yes" in sri:
speak("are you old user or new user")
w2=takecommand().lower()

if 'old user' in w2:


speak("do you forget your password")
w1=takecommand().lower()
print(w1)

if w1=='yes'or w1=="hmm" or w1=="hai":


speak("enter your phone no.")
phone_no=input("enter your phone no.")
speak("enter your new password")
npassword=input("enter your new password")
adminstration.forget(npassword,phone_no)
exit()

else:
speak("please try after some time")

elif "no" in sri:


speak("do you want to be registered")
re=takecommand().lower()
if "yes" in re:
newregistration()

else:
speak("thank you for visiting!!")
else:
speak("i can't recognize you")
exit()

def newregistration():
server = pymysql.connect( host="localhost", user="root",password="Asrmath1053#")
a = server.cursor()

sql="USE jarvis;"
a.execute(sql)

speak("enter your name")


name=input("enter your name")

speak("enter your password")


password=input("enter your password")

speak("enter your email")


email=input("enter your email")

speak("enter your phoneno")


phno=input("enter your phone no")
adminstration.signup(name,password,email,phno)

# taking command function from user


try:
def takecommand():
r = sr.Recognizer()

with sr.Microphone() as source:


print("listing")
r.pause_threshold = 3
audio = r.listen(source)

try:
print("recognizing")
try:
query= r.recognize_google(audio)
except Exception:
speak("please check you internet connection and could you say it again
")
print(query)
return query

except Exception as e:
print(e)

except Exception as k:
speak(k)

# login area ==============#


tprint("welcome")
speak("welcome")
speak("who are you?? old user or new user.")
print("1. new user ")
print("2. old user")
k1=takecommand().lower()
if "old" in k1:
speak('please enter your email')
email = input("enter your email")
str(email)
speak('enter your password')
password= input("enter your password")
str(password)
z=adminstration.admin(email,password)
str(z)
# main content of program started

if z:
speak('welcome')
speak(z)

if __name__ == "__main__":
wish()
while 1==1:
query = takecommand().lower()
if 'time' in query:
time1()

elif 'what is your name' in query:


speak(" i am maith your ai assitant")

elif 'coded you' in query:


speak('ankit kr. srivastava')

elif 'math'in query:


speak("yes")
speak(z)

elif 'in which language your coded' in query:


speak('python version 3.6.2')

elif 'important imports'in query:


try:

f=open('about.txt','r')
speak(f.read())

except Exception:
speak(Exception)

elif 'who am i ' in query:


speak(z)

elif 'do you remember anything' in query:


try:
f =open('data.txt','r')
speak("you said to remember that"+f.read())

except Exception :
speak('you did not say any thing')
elif 'date' in query:
date()

elif 'remember that' in query:


speak("what should i remember")
data = takecommand()
speak("you said that" + data)
data = data + time1() + date()
speak("is it correct")
k = takecommand()
if k=='yes':
r = open('data.txt','w')
r.write(data)
r.close()

elif 'wikipedia' in query:


speak("searching")
query = query.replace("WIKIPEDIA","")
result = wk.summary(query, sentences=3)
print(result)
speak(result)

elif 'send email' in query:


speak("what you want send??")
content = takecommand()
speak("whom you want to send it")
to = input("enter email id")
sendmail(to,content)
speak("email has been send")

elif 'search' in query:


speak("what do you want to serach")
search = takecommand().lower()
driver = webdriver.Chrome("C:\\Program Files (x86)\\Google\\Chrome\\Ap
plication\\chrome.exe")
driver.get(search)
elif 'open chrome' in query:
driver = webdriver.Chrome("C:\\Program Files (x86)\\Google\\Chrome\\Ap
plication\\chrome.exe")

elif 'logout' in query:


os.system("shutdown -1")

elif 'shutdown' in query:


os.system("shutdown /s /t 1")

elif 'restart' in query:


os.system("shutdown /r /t 1")

elif 'play music' in query:


try:
songs_dir ='G:\\Music\\phone'
songs = os.listdir(songs_dir)
os.startfile(os.path.join(songs_dir,songs[0]))
except Exception:
speak(Exception)
print(Exception)

elif 'news' in query:


pasrefeed()

elif 'screenshot' in query:


try:
image =pg.screenshot()
image.save("c:\\users\\hp\\maith ai project\\screenshot")
speak("screenshot taken")
except Exception :
print(Exception)
speak(Exception)

elif 'system status' in query:


cpu()
elif 'joke' in query:
jokes()

elif "database" in query:


speak("enter database host ")
host=input("enter database host")
speak("enter database password")
password=("enter database password")
speak("enter database username")
username=input("enter database username")
speak("what do you want to in databse")
z=takecommand().lower()

if 'create ' and 'database ' in z:


sqlai.create(host,password,username)

if 'query' and 'database' in z:


sqlai.query(host,password,username)

elif 'offline'in query:


exit()

else:
reset()
elif 'new user' in query:
newregistration()
else:
exit()
import pymysql
import sqlite3
import basic
import numpy

def admin(email,password):

server = pymysql.connect( host="localhost", user="root",password="Asrmath1053#")


a = server.cursor()

sql="USE jarvis;"
a.execute(sql)
try:

a.execute('SELECT name FROM password WHERE email = %s AND password = %s',


(email, password,))
k=a.fetchall()

except Exception as e:
print(e)

return k

def forget(npassword,phone_no):
server=pymysql.connect(host="localhost",user="root",password="Asrmath1053#")
a=server.cursor()
sql="use jarvis;"
a.execute(sql)
try:
a.execute('update password set password= %s where phone_no=%s',(npassword,p
hone_no,))
k=a.fechall()
str(k)

except Exception as e:
print(e)

return k
def signup(name,password,email,phno):
server = pymysql.connect( host="localhost", user="root",password="Asrmath1053#")
a = server.cursor()

sql="USE jarvis;"
a.execute(sql)

try:

a.execute("INSERT INTO password VALUES(%s,%s,%s,%s)",(name,password,email,


phno))
server.commit()

except Exception as e:
print(e)

import pymysql
import sqlite3
import basic
import numpy

def create(host,password,username):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("what is the name of database you want to create ")
print("what is the name of database create")
db=basic.takecommand()
k=a.execute("create %s",(db))
if k==True:
basic.speak("do you also want to create a table sir ")
m=basic.takecommand()
if "yes" in m:
basic.speak("what is the name of tables do you want to create ")
table=basic.takecommand()
basic.speak("how many entity for coloum sir")
column=basic.takecommand()
int(column)
a=numpy.array([25])
for n in column:
a[n]=basic.takecommand()

b=numpy.array([25])
for k in column:
b[k]=basic.takecommand()

for f in column:

a.execute("create table %s (%s %s,)",(table,a[f],m[f]))


server.commit()

exit()

def query(host,password,username):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()

basic.speak("which type of query you want to do")


q=basic.takecommand().lower()
if 'select'in q :
basic.speak("which table you want to place query")
table=basic.takecommand()
basic.speak("which column do you want to select")
basic.speak("enter the column name")
column=basic.takecommand()
basic.speak("which entity do you want on which you want to do query")
base=basic.takecommand()
basic.speak("value of that entity")
value=basic.takecommand()

basic.speak("do you want add more specification for query yes or no")
extra=basic.takecommand().lower
if "yes" in extra:
basic.speak("with which coperatorr you want to add specification or /
and")
n=basic.takecommand().lower()
if "and" in n:
basic.speak("which entity do you want on which you want to do que
ry")
base1=basic.takecommand()
basic.speak("value of that entity")
value1=basic.takecommand()
return a.execute("select %s from %s where %s=%s and %s=%s",(colum
n,table,base,value,base1,value1))
server.commit()

if "or" in n:
basic.speak("which entity do you want on which you want to do que
ry")
base1=basic.takecommand()
basic.speak("value of that entity")
value1=basic.takecommand()
return a.execute("select %s from %s where %s=%s or %s=%s",(column
,table,base,value,base1,value1))
server.commit()
else:
return a.execute("select %s from %s where %s=%s",(column,table,base,v
alue))

def update(host,username,password):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("enter table name")
table=input("enter table name")
basic.speak("enter target entity")
entity=input("enter target entity")
basic.speak("enter value of entity")
value=input("enter value of entity")
basic.speak("enter new value")
nvalue=input("enter new value")
try:
a.execute('update %s set value=%s where %s=5s',(table,nvalue,entity,value
,))
server.commit()
except Exception:
print(Exception)
def delete(host,username,password):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("enter table name you want to delete")
table=input("enter table name you want to delete")
basic.speak("enter target entity")
entity=input("enter target entity")
basic.speak("enter value of entity")
value=input("enter value of entity")
a.execute('delete from %s where %s=%s',(table,entity,value,))
server.commit()

def orderby(host,username,password):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("enter target entity")
entity=input("enter target entity")
basic.speak("enter table name")
table=input("enter table name")
basic.speak("order by ascending or descending order")
order=input('ASC for ascending or DESC for decending order')
if order=='ASC' or order=="asc":
a.execute('select %s from %s ORDERBY %s ASC',(entity,table,entity,))
server.commit()

if order=='DESC' or order=="desc":
a.execute('select %s from %s ORDERBY %s DESC',(entity,table,entity,))
server.commit()

def droptable(host,username,password):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("enter table name")
table=input("enter table name")
a.execute('DROP %s',(table))
server.commit()
glimpses
references
• Artificial intelligence with python Prateek joshi.
• www.Pypi.org
• GitHub
• Geeks for geeks
• Stack flow
• www.python.org
• Udemy
• MySQL for python
• Iron man movie.
Our thoughts:

Our thinking is that it is not the ending of this project it’s just
beginning. we will extend its functionality, if AI is future it is our first
step. Learning is not limited to my degree, my degree is not limited to
only what is my course, we will enhance our knowledge and take it
at great level where it will help in our future works.
To be continued………

You might also like