0% found this document useful (0 votes)
11 views30 pages

Dhyey It File

The document contains a practical file for a student named Dhyey R, showcasing various Python and MySQL programs. It includes tasks such as accepting numbers, strings, and generating patterns, along with SQL queries for employee management in a hotel system. The document also outlines the structure of tables for employee and customer data in a hotel management system.

Uploaded by

Daivik Shah 8-B
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)
11 views30 pages

Dhyey It File

The document contains a practical file for a student named Dhyey R, showcasing various Python and MySQL programs. It includes tasks such as accepting numbers, strings, and generating patterns, along with SQL queries for employee management in a hotel system. The document also outlines the structure of tables for employee and customer data in a hotel management system.

Uploaded by

Daivik Shah 8-B
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/ 30

INFORMATION PRACTICES

NAME:- DHYEY R
DHADUK STD:- 11
COMMERCE ROLL NO :-6
YEAR:- 2024-2025
TOPIC:- PRACTICAL FILE
Python Programms
Question 1: Accept three numbers and show which
one is big and which one is small.
a = int(input("enter first no"))
b = int(input("enter second no"))
c = int(input("enter third no"))
if a > b:
if a > c:
print(a, "is big")
if b < c:
print(b, "is small")
else:
print(c, "is small")
else:
print(c, "is big")
print(b, "is smallest")
else:
if b > c:
print(b, "is big")
if a < c:
print(a, "is small")
else:
print(c, "is small")
else:
print(c, "is big")
print(a, "is smallest")

Question 2: Accept a string and change its case.


import os
S = input("enter a sentence")
while True:
os.system("clear")
print("1: uppercase")
print("2: lowercase")
print("3: title")
print("4: capitalize")
a = int(input("enter your choice"))
if a == 1:
print(S.upper())
elif a == 2:
print(S.lower())
elif a == 3:
print(S.title())
elif a == 4:
print(S.capitalize())
elif a == 5:
exit()
elif a > 5:
print("Your choice is wrong")

Question 3: Accept a number of stairs and print a


stair pattern.
n = int(input("Enter the number of stairs: "))
for i in range(1, n + 1):
print("*" * i)

Question 4: Accept a principle amount, rate and type


of interest and show final amount.
P = float(input("Enter a principle amount"))
T = int(input("Enter time in years"))
R = float(input("Enter a rate"))
I = input("Enter a interest")
if I == "simple interest":
print("Simple Interest =", P * R * T / 100)
else:
print("Compound Interest =", P * (1 + R/100)**T)

Question 5: Accept a number of rows and print a number


pyramid pattern.
n = int(input("Enter the number of rows: "))
for i in range(n, 0, -1):
for j in range(1, i + 1):
print(j, end=" ")
print()

Question 6: Accept marks and display grade.


if p > 90:
print(p, "=A1")
elif p > 80 and p <= 90:
print(p, "=A2")
elif p > 70 and p <= 80:
print(p, "=B1")
elif p > 60 and p <= 70:
print(p, "=B2")
elif p > 50 and p <= 60:
print(p, "=C1")
elif p > 40 and p <= 50:
print(p, "=C2")
elif p > 30 and p <= 40:
print("BORDER")
elif p > 20 and p <= 30:
print("FALIURE")
elif p > 10 and p <= 20:
print("Retest or fail the year")
elif p > 0 and p <= 10:
print("Not eligible for School")
elif p <= 0:
print("Specially disabled")
input('Press ENTER to exit')

Question 7: Accept two numbers and swap them.


a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
a, b = b, a
print("Swapped values: a =", a, ", b =", b)

Question 8: Accept a number of rows and print a diamond


pattern.
n = int(input("Enter the number of rows: "))
for i in range(1, n + 1, 2):
print(" " * ((n - i) // 2) + "" * i)
for i in range(n - 2, 0, -2):
print(" " * ((n - i) // 2) + "" * i)

Question 9: Accept a string and count the number of


sentences in it.
s = input("Enter a sentence: ")
l = len(s)
c=0
for i in range(l):
if s[i] in ['.', '!', '?']:
c=c+1
print("Number of sentences =", c)

Question 10: Accept a number and show the sum of digits in


it.
x = int(input("Enter a number: "))
y=0
while x > 0:
r = x % 10
x = x // 10
y=y+r
print("Sum of digits =", y)

Question 11: Accept a string and store characters in


separate lists based on odd and even ASCII values.
s = input("Enter a string value")
ol = []
el = []
for i in s:
if ord(i) % 2 == 0:
el.append(i)
else:
ol.append(i)
print(ol)
print(el)

Question 12: Accept two numbers and print sum of


them.
a = int(input("Enter first no"))
b = int(input("Enter second no"))
c=a+b
print("Sum of the two numbers =", c)

Question 13: Accept a string and convert it to


uppercase.
text = input("Enter a string: ")
print("Uppercase:", text.upper())

Question 14: Accept a number and check if it is a


palindrome.
Variant 1:

a = input("Enter a number: ")


if a == a[::-1]:
print("Palindrome number")
else:
print("Not a palindrome number")

Variant 2:

a = int(input("Enter a number: "))


b=0
c=a
while a > 0:
r = a % 10
b = b * 10 + r
a = a // 10
if b == c:
print("The number is a palindrome")
else:
print("The number is not a palindrome")

Question 15: Accept a number and show the sum of


the cubes of its digits.
x = int(input("Enter a number: "))
y=0
while x > 0:
r = (x % 10) ** 3
x = x // 10
y=y+r
print("Sum of the cubes of digits =", y)

Question 16: Accept a name and print a greeting


message.
n = input("Enter your name")
g = input("Enter your gender")
t = int(input("Enter the time"))
if t < 12:
if g == "Male":
print("Good Morning", n, "Sir")
if g == "Female":
print("Good Morning", n, "Ma'am")
else:
if g == "Male":
print("Good Evening", n, "Sir")
if g == "Female":
print("Good Evening", n, "Ma'am")
input('Press ENTER to exit')

Question 17: Accept a number and show that is it


odd or even.
N = int(input("enter a no"))
R=N%2
if R == 0:
print("Number is even")
else:
print("Number is odd")

Question 18: Accept a number of rows and columns


and print a quadrilateral pattern.
rr = int(input("Enter number of rows: "))
cc = int(input("Enter number of columns: "))
for i in range(1, rr + 1):
for j in range(1, cc + 1):
print(i + 1, end=" ")
print()

Question 19: Accept a number of stairs and print an


inverted stair pattern.
n = int(input("Enter the number of stairs: "))
for i in range(n, 0, -1):
print("*" * i)

Question 20: Accept a string and count the number


of words in it.
s = input("Enter a sentence: ")
l = len(s)
w=0
for i in range(l):
if s[i] in [' ']:
w=w+1
print("Number of words =", w)

Question 21: Accept a sentence and store all words


in a list.
sentence = input("Enter a sentence: ")
words = sentence.split()
print("Words list:", words)

Question 22: Accept a string and store characters in a list


separated by commas.
s = input("Enter a string value")
print(s.split())
for i in range(len(s)):
print(s[i], end=",")
print()

Question 23: Accept a value and shape and display


the area.
A = int(input("enter any value"))
S = input("enter any shape")
if S == "Square":
print("area=", A2)
elif S == "Circle":
print("area=", 3.14 * A2)
import os
os.system("pause")

Question 24: Accept a word and print a stair pattern


of it.
s = input("Enter a word: ")
l = len(s)
for i in range(l, 0, -1):
for r in range(i):
print(s[r], end="")
print()

Question 25: Accept a number of rows and print a


pyramid pattern.
for r in range(1, 5):
for b in range(1, 5 - r):
print(" ", end=" ")
for c in range(1, r + 1):
print("", end=" ")
for c1 in range(1, r):
print("", end=" ")
print()

Question 26: Accept a string and count the number


of vowels in it.
s = input("Enter a sentence: ")
l = len(s)
c=0
for i in range(l):
if s[i] in ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']:
c=c+1
print("Number of vowels =", c)
MYSQL Programms
Table 1 :- emp
Emp_i Ename Doj Sal Desig
d
1 Shrey 2017-04- 10000 CEO
02
2 Preet 2018-05- 8000 Manag
12 er
3 Rudra 2018-02- 8000 Manag
14 er
4 Parth 2020-09- 7000 Clerk
23
5 Jatin 2023-08- 6000 Design
13 er
6 Dhyey 2021-01- 4500 Assista
01 nt
7 Henil 2020-09- 5000 Technic
11
8 Yash 2019-03- 4000 Clerk
21
ss9 Vraj 2023-03- 6000 Design
21 er
10 Megh 2024-07- 6000 Manag
17 er
Table 2 :- dpt
Did Dnm Dpt_Floor
1 CEO 3
2 Manager 2
3 Designer 1
4 Technic 1
5 Assistant 0
Question 1 display all employees name who are working as
manager
select * from emp where Desig = ‘Manager’:

Question 2 display employees name and salary based on


salary whose salary is less than 5000. And Desig = ‘Clerk’
select Ename,Sal from emp where sal<5000 and Desig = ‘Clerk’;

Question 3:- Display all emp info who join industry in 2020
Select * from emp where year(Doj) = 2020;

Question 4:- Display Ename and id whose id is greater than


2 and name having s character
select Ename,Emp_id from emp where Emp_id > 102 and Ename =
‘%s’,’s%’,’%s%’;

Question 5:- Display emp name and doj and sal except
manager post
Select Ename,Doj,Sal from emp where Desig!=’Manager’;

Question 6:- Display all the post


Select Desig from emp;

Question 7:- Find min and max sal


select min(Sal),max(Sal);
Question 8:- Check how many record you have
Select count(*) from emp;

Question 10:- Display first four characters of Ename


select Ename from emp where Ename = ‘____’;

Question 11:- Display all info of Shrey


Select * from emp where Ename = ‘Shrey’;

Question 12:- How many records you have


Select count(*) from emp;

Question 13:- Display all those record whose sal not yet
decided
Select * from emp where Sal is NULL;

Question 14:- Display all those employes who join today


Select * from emp where Doj = sysdate;

Question 15:- Display name and dpt name who join in march
2024
Select Ename,Dnm from emp.dpt where month(Doj) = 3 and
year(Doj) = 2024;

Question 16:- Display all emp info arranged in sal


descending order except hr department
Select * from emp where Desig != HR and order by sal(desc);

Question 17:- Identify the salary gap of all employs


Select average(Sal) from emp;

Question 18:- Display emp name monthly sal and annual


salary
Select Sal,Sal*12 as Monthly sal,Annual Sal from emp;

Question 19:- Display job experience of all employes


Select Ename,Curdate – Doj as Ename,Experience from emp;

Question 20:- Display Ename dptname and sal who work as


clerk with ending letter as ‘ta’
Select Ename , Desig , Sal from emp where Desig=’Clerk’ and
Ename =’%ta’ ;

Question 21:- Display the first name of all employes


Select left(Ename,instr(Ename,’ ‘)) from emp

Question 22:- Display all employes having six letters in


name only
Select Ename from emp where Ename =’______’;

Question 23:- Display all emp info whose surname start with
‘s’
Select * from emp where right(Ename) = ‘s’ or right(Ename) = ‘S%’;

Question 24:- Display total Salary as per desig


Select sum(Sal) from emp order by Desig;

Question 25:- Display no of employes as Desig


Select Desig,count(*) from emp group by Desig;

Question 26:- Count all the employes desigwise except hr


desig and sal more than 5000
Select Desig,count(*) from emp where sal > 5000 group by Desig
having Desig != ‘HR’;

Question 27:- Show all employes which having Dpt employes


more than two
Select emp from emp having count(desig) > 2;
Question 28:- Display ename whose sal is less than average
sal
Select Ename from emp where Sal <(select average(Sal)from
emp);

Question 29:- Display Ename whose dpt floor is 0


Select Ename,Did from emp,dpt;

Question 30:- Display all emp info and average sal


Select * from emp where sal is average(Sal)

HOTEL
MANAGEMENT
system

import mysql.connector as
sql
con=sql.connect(host="local
host",
user="root",password="Vis
ma@12 3")
cur=con.cursor()
cur.execute("create
database if not exists
dhyeyproject")
cur.execute("use
dhyeyproject") ## room
table ## cur.execute("create
table if not exists room
(roomid int (50) primary
key , roomtype varchar (10),
roomvacancy int(1),
roomcost float(10,2),
roomfacilities varchar (30))")
## customer table ##
cur.execute("create table if
not exists customer (cid int
(50) primary key , cnm
varchar (70), cad varchar
(100), cgen varchar (20),
cdob date , cidproof int (20),
ccid date, ccod date, crtype
varchar (20), crcost
float(10,2), crid int (50), csa
varchar (50), nop int (10),
pot varchar (30), ap float
(10,2))")
## employee table ##
cur.execute("create table if
not exists employee
(employeeid int(20),
employeename varchar
(100), departmentname
varchar
(20), designation varchar
(30),
salary float
(10))") ##
service table ##
cur.execute("create table if
not exists service (roomid int
(10), dining int (20), laundry
int (20), roomservice int
(10), totalamt int (10))")
## room add
def## def
roomadd():
roomid=int(input("enter
room id
"))
roomtype=input("enter
the
room type")
roomvacancy=int(input("e
nter
the vacancy of the room"))
roomcost=float(input("ent
er the cost of the room"))
roomfacalities=input("ente
r the facalities of the room
available")
cur.execute(f"insert into
room
values({roomid},'{roomtype
}',0,
{roomcost},'{roomfacalitie
s}')") con.commit()
print("record saved")
f=int(input("enter any
number
too continue"))
##room modify def
## def roommodify():
rid=int(input("enter your
room id "))
print("enter your thing to
be modify ")
print("""1.room type
2. room vacancy
3. room cost
4. room facalities""")
ch=int(input("enter your
choice
"))
if ch==1:
rt=input("enter the room
type")
cur.execute("update
room set roomtype ={rt}
where roomid={rid}")
elif ch==2 :
rv=input("enter the
vacancy of the room ")
cur.execute ("update
room set vacancy = {rv}
where roomid={rid}")
elif ch==3:
rc=float(input("enter
the cost
of the room"))
cur.execute("update
room set cost={rc} where
roomid=(rid}")
elif ch==4:
rf=input("enter the
new
facalities of the room")
cur.execute("update
table
room set facalities= {rf}
where roomid={rid}")
## room details
def## def
roomdetails():
cur.execute("select * from
room
")
recs=cur.execute("fetch all
")
## room remove def
## def
roomremove():
ri=int(input("enter the
room id which is to be
deleted "))
cur.execute("delete from
room where room id =ri")
##customer add
def ## def
customeradd():
cid=int(input("enter the
customer id of the customer
"))
cnm=input("enter the
name of the customer ")
cad=input("enter the
address of the customer ")
cgen=input("enter the
gender of the customer ")
cdob=input("enter the
date of birth of customer ")
cidproof=int(input("enter
the id proof number of the
customer "))
ccid=input("enter the
check in date of the
customer ")
ccod=input("enter the
check out date of the
customer ")
crtype =input("enter the
type of the room of customer
")
crcost=int(input("enter
the cost of the room of the
customer "))
crid=int(input("enter the
room id of the room id of
the customer "))
csa=input("enter the
service availed by the
customer ")
nop=int(input("enter the
number of person with the
customer "))
pot=input(" enter the
purpose of travel of the
customer ")
ap=int(input("enter the
amount to be paid by the
customer "))
cur.execute(f"insert into
customer
values({cid},'{cnm}','{cad}
','{cge n}','{cdob}',
{cidproof},'{ccid}','{ccod}
','{crty
pe}',{crcost},
{crid},'{csa}',
{nop},'{pot}',
{ap})") ##room
menu ##
def roommenu():
print("""1.room add
2. room modify
3. room remove
4. display room details
5. back to main
menu""")
ch=int(input("input
your
choice"))
if ch==1:
roomadd()
elif ch==2:
roommodify(
)
elif ch==3:
roomremove()
elif ch==4:
roomdetails(
)
elif
ch==5
:
return
## customer
menu## def
customermenu():
print("""1.customer add
2. customer details modify
3. customer remove
4. display customer details
5. back to main menu """)
ch=int(input("enter your
choice
"))
if ch==1:
customeradd()
elif ch==2:
pass
elif
ch==3
: pass
elif
ch==4
: pass
else :
return
## employmenu
## def
employeemenu():
print("""1.employee add
2. employee details modify
3. employee remove
4. display employee details
5. back to main menu """)
ch=int(input("enter your
choice
"))
if
ch==1
: pass
elif
ch==2
: pass
elif
c if
h ch==5
= :
= return
3
:

p
a
s
s
el
i
f

c
h
=
=
4
:

p
a
s
s
el
##service
menu## def
servicemenu():
print("""1. service add
2. service details modify
3. service remove
4. service details
5. back to main menu """)
ch=int(input("enter the
choice
"))
if
ch==1
: pass
elif
ch==2
: pass
elif
ch==3
: pass
elif
ch==4
: pass
elif
ch==5
:
return
##mainmenu
### while True:
print("welcome to the
hotel management system
of jaymeel ")
print('''1.room
2.customer
3.employee
4.service
5.exit''')
ch=int(input("input
your choice"))
if ch==1:
roommenu()
elif ch==2:
customermenu()
elif ch==3:
employeemenu()
elif ch==4:
servicemenu
() exit()

You might also like