0% found this document useful (0 votes)
17 views35 pages

Love Merge

Uploaded by

Shreyansh Jain
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)
17 views35 pages

Love Merge

Uploaded by

Shreyansh Jain
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/ 35

ARTIFICIAL INTELLIGENCE

PRACTICAL FILE
SESSION: 2024-2025

SUBMITTED TO: SUBMITTED BY:


Ms YUKTI AGARWAL Name – SHREYANSH JAIN
Class -
Roll No. -
INDEX OF PYTHON PROGRAMS

S.NO TITLE PRACTICAL SIGNATURE


DATE
1. WAP to read a number n and print n2, n3 19/04/2024
and n4.
2. WAP to print the table of a given number 22/04/2024
in the format 2X1 =2.
3. WAP to input a single digit n and print a 06/05/2024
3-digit number created as <n(n+1)(n+2)>
(Hint-if n=7 then it should display 789 in
output)
4. WAP to make a menu driven list for 10/05/2024
perimeter and area of different shapes.
5. WAP to read three numbers and print them 13/05/2024
in ascending order.
6. WAP to print factorial of a given number. 26/07/2024
7. WAP to check that whether a given 26/07/2024
number is prime or not.
8. WAP to print Fibonacci series of first 20 29/07/2024
elements.
9. WAP to print first 20 Mersenne numbers. 29/07/2024
(Hint: Mersenne numbers are 2n−1)
10. WAP to print the following patterns: 04/08/2024
(a) 1 (b) 4321
13 432
135 43
1357 4
11. WAP to print the following series: 12/08/2024
(Hint: Input the values of x and n)
(a) 1+x+x2+x3+x4…….xn
(b) 1-x+x2–x3+x4…….xn
12. WAP to check that whether a given string 23/08/2024
is palindrome or not.
13. WAP to reverse words in a given string in 23/08/2024
python.
14. WAP to count number of vowels in given 30/08/2024
string.
15. WAP to swap commas and dots in a given 30/08/2024
string.
INDEX OF SQL PROGRAMS

S. NO TITLE PRACTICAL SIGNATURE


DATE
1. Write SQL commands to: 30/09/2024
1. Create a database ‘Hospital’.
2. Create a table ‘Doctor’.
3. Display the structure of the table
‘Doctor’.
4. Add one more column in the table.
5. Insert a record in table.
6. Change the data-type of a column.
7. Rename the column name.
8. Delete a column.
9. Delete the table ‘Doctor’.

2. Write SQL commands to: 07/10/2024


1. Display the details of all employees.
2. Display name and designation of those
employees whose S-GRADE is either
S02 or S03.
3. Display details of the employees
whose DOJ is between 9/2/2006 and
08/08/2009.
4. Populate one more tuple in the table.
5. Display the details of all employees
whose salary is greater than 30000.
6. Display all unique S-GRADES.

3. Write SQL commands to: 18/10/2024


1. Display all the products whose
quantity is 200.
2. Display data for all products whose
cost is more than 40.
3. List S_name, P_name, cost for all the
products whose quantity is less than
300.
4. Display S.no, P_name, S_name, Qty
for Mumbai city from the SHOP
table.
4. Write SQL commands to: 21/10/2024
1. Display the car name along with the
charges rounded off to 1-digit after
decimal place.
2. Display the car name, color and
position of the character ‘E’ in the color
of all the cars.
3. Display the car name, name of the
company in lowercase of all cars whose year
of manufacturing is 2020.
4. Display the number of cars
manufactured in each year.
5. Write a python program to establish the 10/11/2024
connection with MySql and:
1. Create a database EMPS.
2. Create a table INFO.
3. Insert the rows in the table.
4. Display all the details of the table.
WAP to read a number n and print n2, n3 and n4

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


n=int(input('enter a no. = '))
a=n**2
b=n**3
c=n**4
print(n, a, b, c, sep=’,’)

WAP to print the table of a given number in the format 2X1 =2

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


n=int(input('enter a no. for table = '))
for i in range(1,11,1):
print(n, 'X', i, '=', n*i)
WAP to input a single digit n and print a 3-digit number created as <n(n+1)(n+2)>
(Hint-if n=7 then it should display 789 in output)

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


n=int(input('enter a no. = '))
a=str(n)
for i in range(1,3,1):
a = a + str(n+i)
print(a)
WAP to read three numbers and print them in ascending order

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


a=int(input('enter a no. = '))
b=int(input('enter a no. = '))
c=int(input('enter a no. = '))
if a>b and a>c:
if b>c:
print(c, '<', b, '<', a)
else:
print(b, '<', c, '<', a)
elif b>a and b>c :
if a>c:
print(c, '<', a, '<', b)
else:
print(a, '<', c, '<', b)
elif c>a and c>b:
if a>b:
print(b, '<', a, '<', c)
else:
print(a, '<', b, '<', c)
WAP to print factorial of a given number

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


n=int(input('enter a no. to find factorial = '))
f=1
for i in range(1,n+1,1):
f= f*i
print(n, 'factorial =', f)

WAP to check that whether a given number is prime or not

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


n=int(input('enter a no. to check prime = '))
a=0
for i in range (1,n,1):
if n%i== 0:
a=a+1
if a>1 :
print(n, 'is not a prime no.')
else:
print(n, 'is a prime no.')
WAP to print Fibonacci series of first 20 elements

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


l=[0,1]
n=20
for i in range(0, n-2):
a=l[-1]+l[-2]
l.append(a)
for i in l:
print(i, end=' ')

WAP to print first 20 Mersenne numbers. (Hint: Mersenne numbers are 2n−1)

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


for i in range (1,21,1):
print((2**i)-1, end=' ')
WAP to print the following patterns:
a) 1
13
135
1357

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


l=str(1)
print(l)
for i in range(3,8,2):
l= l + str(i)
print(l)

b) 4321
432
43
4
WAP to print the following series (Hint: Input the values of x and n) :
a) 1+x+x2+x3+x4…….xn

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


x=int(input('enter a no. = '))
n=int(input('enter the power = '))
s=0
l=1
for i in range(0,n+1):
s=s+(x**i)
for i in range(1,n+1):
l=str(l) + str('+') + str(x) + str('^') + str(i)
print(l, '=', s)
b) 1-x+x2–x3+x4…….xn

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


x=int(input('enter a no. = '))
n=int(input('enter the power = '))
a=0
b=1
for i in range(0,n+1):
a = a + (((-1)**i)*(x**i))
for i in range(1, n+1):
if i%2==0:
b= str(b) + str('+') + str(x) + str('^') + str(i)
else:
b= str(b) + str('-') + str(x) + str('^') + str(i)
print(b, '=', a)

WAP to check that whether a given string is palindrome or not

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


l=input('enter a line or word to check palindrome = ')
l=l.upper()
if l[::1] == l[::-1] :
print(l, 'is a palindrome')
else:
print(l, 'is not a palindrome')
WAP to reverse words in a given string in python

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


l=input('enter a word = ')
print('reverse word is', l[::-1])

WAP to count number of vowels in given string

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


l=input('enter a word or line to count number of vowels = ')
v=0
for i in l:
if str(i) in 'AEIOUaeiou':
v=v+1
print('number of vowels in', l, '=', v)
WAP to swap commas and dots in a given string

print('*********PROGRAMMER NAME : SHREYANSH JAIN*********')


l=input('enter a line = ')
a=[]
b=''
for i in l:
a.append(i)
for j in range (0, len(a), 1) :
if a[j]==',':
a[j]='.'
elif a[j]=='.':
a[j]=','
for i in a :
b = b+ str(i)
print('after swapping dots and commas = ', b)
SOURCE
CODE
import mysql.connector

# Establish the database connection


connection = mysql.connector.connect(
host="localhost",
user="root",
password="mysql",
charset='utf8'
)

cursor = connection.cursor()

# Create the database


cursor.execute("CREATE DATABASE IF NOT EXISTS restaurant")
cursor.execute("USE restaurant")

# Create 'menu' table


cursor.execute("""
CREATE TABLE IF NOT EXISTS menu (
ID INT PRIMARY KEY,
DISH_NAME VARCHAR(100) NOT NULL,
PRICE DECIMAL(10, 2) NOT NULL,
TYPE VARCHAR(50) NOT NULL
)
""")

# Customer details
cursor.execute("""
CREATE TABLE IF NOT EXISTS cusdet (
ORDER_ID INT AUTO_INCREMENT PRIMARY KEY,
QUANTITY INT NOT NULL,
NAME VARCHAR(100) NOT NULL,
MOBNO INT NOT NULL,
ADDRESS VARCHAR(255) NOT NULL,
ITEM_NAME VARCHAR(100) NOT NULL,
TOTAL_PRICE DECIMAL(10, 2) NOT NULL
)
""")

# Create 'feedback' table


cursor.execute("""
CREATE TABLE IF NOT EXISTS feedback (
ID INT AUTO_INCREMENT PRIMARY KEY,
NAME VARCHAR(100) NOT NULL,
MESSAGE TEXT NOT NULL
)
""")

# Function to view the menu


def vmen():
cursor.execute("SELECT * FROM menu")
menu = cursor.fetchall()

if menu:
print("\nAvailable Dishes:")
for dish in menu:
print(f"{dish[0]}. {dish[1]} - {dish[3]} - Rs{dish[2]}")
else:
print("No dishes available.")
choice = input("\nDo you want to order? (yes/no): ").strip().lower()
if choice == 'yes':
byo()
print("\nChoose Delivery Method:")
print("1. Home Delivery")
print("2. Pick-Up")
choice = input("Enter your choice: ").strip()

if choice == '1':
print("Home delivery selected. Your order will be delivered shortly.")
elif choice == '2':
print("Pick-Up selected. Your order will be ready for collection.")
else:
print("Invalid choice. Defaulting to Home Delivery.")
print("Home delivery selected. Your order will be delivered shortly.")
print("\nChoose Payment Method:")
print("1. Cash on Delivery")
print("2. Online Payment")
choice = input("Enter your choice: ").strip()

if choice == '1':
print("Cash on Delivery selected. Please prepare the exact amount.")
elif choice == '2':
print("Online Payment selected. You will receive payment details shortly.")
else:
print("Invalid choice. Defaulting to Cash on Delivery.")
print("Cash on Delivery selected. Please prepare the exact amount.")
else:
print("Goodbye!")
# Function to place an order
def byo():
try:
dish_id = int(input("Enter dish number to order: "))
quantity = int(input("Enter quantity: "))
query = "SELECT * FROM menu WHERE ID = " + str(dish_id)
cursor.execute(query)
dish = cursor.fetchone()

if dish:
dish_name = dish[1]
price = dish[2]
total_price = price * quantity

name = input("Enter your name: ")


mobno = int(input("Enter your mobile number: "))
address = input("Enter your address: ")

insert_query = f"""
INSERT INTO cusdet (QUANTITY, NAME, MOBNO, ADDRESS, ITEM_NAME,
TOTAL_PRICE)
VALUES ({quantity}, '{name}', {mobno}, '{address}', '{dish_name}', {total_price})
"""
cursor.execute(insert_query)
print(f"\nOrder placed! Total: Rs{total_price}")
connection.commit()
else:
print("Dish not found.")
except ValueError:
print("Invalid input. Please enter valid data.")

# Function to submit feedback


def fdbck():
name = input("Enter your name: ")
message = input("Enter your feedback: ")

if message:
insert_query = f"""
INSERT INTO feedback (NAME, MESSAGE)
VALUES ('{name}', '{message}')
"""
cursor.execute(insert_query)
print("Thank you for your feedback!")
connection.commit()
else:
print("Feedback cannot be empty.")

# Function to view orders


def view_orders():
cursor.execute("SELECT * FROM cusdet")
orders = cursor.fetchall()

if orders:
print("\nOrders:")
for order in orders:
print(f"Order ID: {order[0]}, Name: {order[2]}, Item: {order[5]}, Quantity: {order[1]}, Total: $
{order[6]}, Address: {order[4]}")
else:
print("No orders found.")
# Function to generate bill
def generate_bill(order_id):
try:
query = f"SELECT * FROM cusdet WHERE ORDER_ID = {order_id}"
cursor.execute(query)
order = cursor.fetchone()

if order:
print("\n--- Bill ---")
print(f"Order ID: {order[0]}")
print(f"Customer Name: {order[2]}")
print(f"Mobile Number: {order[3]}")
print(f"Address: {order[4]}")
print(f"Item Name: {order[5]}")
print(f"Quantity: {order[1]}")
print(f"Total Price: Rs{order[6]}")
print("----------------")
else:
print("Order not found.")
except ValueError:
print("Invalid input. Please enter a valid Order ID.")

# Main function to run the system


def main():
while True:
print("\nWelcome to the Food Ordering System!")
print("1. View Menu")
print("2. View Orders")
print("3. Generate bill")
print("4. Submit Feedback")
print("5. Exit")

choice = input("Choose an option: ").strip()

if choice == '1':
vmen()
elif choice == '4':
fdbck()
elif choice == '2':
view_orders()
elif choice == '3':
view_orders()
try:
order_id = int(input("Enter Order ID to generate bill: "))
generate_bill(order_id)
except ValueError:
print("Invalid input. Please enter a valid Order ID.")
elif choice == '5':
print("Exiting...")
break
else:
print("Invalid choice. Please try again.")
main()
cursor.close()
connection.close()
MYSQL
Tables in database ‘restaurant’ :

Description and data in table cusdet :


Description and data in table menu;
Description and data in table feedback :
BIBILOGRAPHY

www.google.com
www.wikipedia.org
www.yahoo.com
Class XII Computer Science NCERT Textbook
View menu :

Ordering a dish and selecting delivery and payment option :


View orders :

Submitting a feedback :

To generate bill :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy