Saturday 23 January 2021
Game 4: Tic Tac Toe Game in Python
Conflict Serializability questions of DBMS
Conflict Serializability questions of DBMS
1). Check whether the schedules is conflict serializable or not
S : R2(A); W2(A); R3(C); W2(B); W3(A); W3(C); R1(A); R1(B); W1(A); W1(B)
2). Check whether the schedule are conflict serializable or not
S : R2(A); R3(C); W3(A); W2(A); W2(B); W3(C); R1(A); R1(B); W1(A); W1(B)
3). Check whether the schedule is conflict serializable or not?
S: R1(A); R2(A); R3(B); W1(A); R2(C); R2(B); W2(B); W1(C)
4). Check whether the schedule is conflict serializable or not?
S: W3(A); R1(A); W1(B); R2(B); W2(C); R3(C)
5). Check whether the schedule is conflict serializable or not?
S: R2(x); W3(x); W1(y); R2(y); W2(z)
6). Consider three data items D1,D2, and D3, and the following execution schedule of transactions T1, T2, and T3. In the diagram, R(D) and W(D) denote the actions reading and writing the data item D respectively.
S: R2(D3); R2(D2); W2(D2); R3(D2); R3(D3); R1(D1); W1(D1); W3(D2); W3(D3); R2(D1); R1(D2);
W1(D2); W2(D1)
7). Check whether the schedule is conflict serializable or not?
S: R3(y); R3(z); R1(x); W1(x); W3(y); W3(z); R2(z); R1(y); W1(y); R2(y); W2(y); R2(x); W2(x)
8). Check whether the schedule is conflict serializable or not?
S: R3(y); R3(z); R1(x); W1(x); W3(y); W3(z); R2(z); R1(y); W1(Y); R2(y); W2(y)
9). Check whether the schedule is conflict serializable or not?
S: R2(A); R1(B); W2(A); R3(A); W2(B); W3(A); R2(B); W2(B)
10). Check whether the schedule is conflict serializable or not?
S: R1(X); R3(Z); W3(Z); R2(Y); R1(Y); W2(Y); W3(X); W2(Z);W1(X)
11). Check whether the schedule is conflict serializable or not?
S: R1(X); R2(Y); R3(Y); W2(Y); W1(X); W3(X); R2(X); W2(X)
12). Check whether the schedule is conflict serializable or not?
S: R1(B); R3(C); R1(A); W2(A); W1(A); W2(B); W3(A); W1(B);W3(B);W3(C)
13). Check whether the schedule is conflict serializable or not?
S: R2(X); W3(X); C3; W1(X); C1; W2(Y); R2(Z); C; R4(X); R4(Y); C4
Friday 22 January 2021
Practical - 24: Python MySql Connectivity for class 12 CS and IP
Practical - 24: Python MySql Connectivity for class 12 CS and IP
'''Write a menu driven program to demonstrate add, display, update, delete and exit.
Performed on a table movie containing (mid, mname, rating) through
python-MySql connectivity.'''
import mysql.connector
con=mysql.connector.connect(host="localhost",username="root",passwd="root")
mycursor=con.cursor()
mycursor.execute("create database if not exists spsharmag")
mycursor.execute("use spsharmag")
mycursor.execute("create table if not exists movie (mid int primary key,mname varchar(20),rating float(5,2))")
c="y"
while(c=="y" or c=="Y"):
print("1. Press 1 for add new movie: ")
print("2. Press 2 for Show the details of movie: ")
print("3. Press 3 for Update movie Details: ")
print("4. Press 4 for Delete movie Details: ")
print("5. Press 5 for Exit: ")
choice=int(input("Enter Your Choice 1 or 2 or 3 or 4 or 5: "))
if(choice==1):
mid=int(input("Enter movie Id: "))
mname=input("Enter movie Name: ")
rating=float(input("Enter movie rating: "))
mycursor.execute("insert into movie values(%s,%s,%s)",(mid,mname,rating))
con.commit()
elif(choice==2):
mycursor.execute("select * from movie")
mymovies=mycursor.fetchall()
for x in mymovies:
print(x)
elif(choice==3):
mid=int(input("Enter the movie id for update: "))
mname=input("Enter movie New Name: ")
rating=float(input("Enter movie New Rating: "))
mycursor.execute("update movie set mname=%s,rating=%s where mid=%s",(mname,rating,mid))
con.commit()
elif(choice==4):
mid=int(input("Enter the movie id for delete: "))
mycursor.execute("delete from movie where mid=%s",(mid,))
con.commit()
elif(choice==5):
break
else:
print("Wrong Choice")
c=input("Press 'y' for continue and 'n' for exit: ")
Practical - 21: Python MySql Connectivity for class 12 CS and IP
Practical - 21: Python MySql Connectivity for class 12 CS and IP
'''Practical No. 21: Write a menu driven program to demonstrate add, display, update, delete and exit. Performed on a table product containing (pid, pname, pprice) through python-MySql connectivity.'''
import mysql.connector
con=mysql.connector.connect(host="localhost",username="root",passwd="root")
mycursor=con.cursor()
mycursor.execute("create database if not exists spsharmag")
mycursor.execute("use spsharmag")
mycursor.execute("create table if not exists product (pid int primary key,pname varchar(20),pprice float(5,2))")
c="y"
while(c=="y" or c=="Y"):
print("1. Press 1 for add new product: ")
print("2. Press 2 for Show the details of product: ")
print("3. Press 3 for Update product Details: ")
print("4. Press 4 for Delete product Details: ")
print("5. Press 5 for Exit: ")
choice=int(input("Enter Your Choice 1 or 2 or 3 or 4 or 5: "))
if(choice==1):
pid=int(input("Enter product Id: "))
pname=input("Enter product Name: ")
pprice=float(input("Enter product Price: "))
mycursor.execute("insert into product values(%s,%s,%s)",(pid,pname,pprice))
con.commit()
elif(choice==2):
mycursor.execute("select * from product")
myproducts=mycursor.fetchall()
for x in myproducts:
print(x)
elif(choice==3):
pid=int(input("Enter the product id for update: "))
pname=input("Enter product New Name: ")
pprice=float(input("Enter product New Price: "))
mycursor.execute("update product set pname=%s,pprice=%s where pid=%s",(pname,pprice,pid))
con.commit()
elif(choice==4):
pid=int(input("Enter the product id for delete: "))
mycursor.execute("delete from product where pid=%s",(pid,))
con.commit()
elif(choice==5):
break
else:
print("Wrong Choice")
c=input("Press 'y' for continue and 'n' for exit: ")
Practical - 20: Python MySql Connectivity for class12 CS and IP
Practical - 20: Python MySql Connectivity Program for class 12 CS and IP
'''Write a menu driven program to demonstrate add, display, update, delete and exit. Performed on a table Book containing
(bid, bname, bprice) through python-MySql connectivity.'''
import mysql.connector
con=mysql.connector.connect(host="localhost",username="root",passwd="root")
mycursor=con.cursor()
mycursor.execute("create database if not exists spsharmag")
mycursor.execute("use spsharmag")
mycursor.execute("create table if not exists book (bid int primary key,bname varchar(20),bprice float(5,2))")
c="y"
while(c=="y" or c=="Y"):
print("1. Press 1 for add new book: ")
print("2. Press 2 for Show the details of Books: ")
print("3. Press 3 for Update Book Details: ")
print("4. Press 4 for Delete Book Details: ")
print("5. Press 5 for Exit: ")
choice=int(input("Enter Your Choice 1 or 2 or 3 or 4 or 5: "))
if(choice==1):
bid=int(input("Enter Book Id: "))
bname=input("Enter Book Name: ")
bprice=float(input("Enter Book Price: "))
mycursor.execute("insert into book values(%s,%s,%s)",(bid,bname,bprice))
con.commit()
elif(choice==2):
mycursor.execute("select * from book")
mybooks=mycursor.fetchall()
for x in mybooks:
print(x)
elif(choice==3):
bid=int(input("Enter the book id for update: "))
bname=input("Enter Book New Name: ")
bprice=float(input("Enter Book New Price: "))
mycursor.execute("update book set bname=%s,bprice=%s where bid=%s",(bname,bprice,bid))
con.commit()
elif(choice==4):
bid=int(input("Enter the book id for delete: "))
mycursor.execute("delete from book where bid=%s",(bid,))
con.commit()
elif(choice==5):
break
else:
print("Wrong Choice")
c=input("Press 'y' for continue and 'n' for exit: ")
Thursday 21 January 2021
Game No. 3: Flappy Birds Game in Python
Game No. 3: Flappy Birds Game in Python
import pygame
import random,sys
pygame.init()
clock = pygame.time.Clock()
screen = pygame.display.set_mode((800,600))
pygame.display.set_caption("FLAPPY BIRDS")
#BIRD
x = 200
y = 300
jump = 0
speed = 0.5
def draw_circle(x,y):
pygame.draw.circle(screen, (255,0,0), (x,y), 30)
#PIPES
pipe1 = [800, 0, 50, random.randint(20,250)]
pipe2 = [400, 0, 50, random.randint(50,250)]
Pipes = []
Pipes.append(pipe1)
Pipes.append(pipe2)
def draw_pipes(PIPE):
#left, top, width, heihgt
#TOP
pygame.draw.rect(screen, (0,255,0), (PIPE[0], PIPE[1], PIPE[2], PIPE[3]))
#BOTTOM
pygame.draw.rect(screen, (0,255,0), (PIPE[0], 150+PIPE[3], PIPE[2], PIPE[3]+400))
score = 0
running = True
while running:
screen.fill((120,120,255))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE: jump = 1
if event.type == pygame.KEYUP:
if event.key == pygame.K_SPACE: jump = 0
#BIRD MOVEMENT
draw_circle(x,y)
if jump == 1:
y -= 3
else:
y += speed
#PIPE MOVEMENT
for i in Pipes:
draw_pipes(i)
i[0] -= 3
if i[0] < 0:
i[0] = 800
i[3] = random.randint(50,250)
#GAME OVER AND SCORE
for i in Pipes:
if i[0] == 200:
if y <= i[3] or y >= 150+i[3]:
print("GAME OVER")
running = False
pygame.quit()
sys.exit()
elif i[3] < y < 150+i[3]:
score += 1
print(score)
clock.tick(30)
pygame.display.update()
Game No. 2 : SPACE INVADERS Game in Python
Game No. 2 : SPACE INVADERS Game in Python
import pygame
import random
import math,sys
#INITIALISING PYGAME
pygame.init()
#SCREEN
screen = pygame.display.set_mode((800,600))
#TITLE
pygame.display.set_caption("SPACE INVADERS")
#BACKGROUND
background = pygame.image.load('imgs/background.png')
#pygame.mixer.music.load('sounds/background.wav')
#pygame.mixer.music.play(-1)
#PLAYER
playerimg = pygame.image.load('imgs/si.png')
pX = 360
pY = 480
pXchange = 0
pYchange = 0
speed = 5
def player(x,y):
screen.blit(playerimg, (x,y))
#ENEMY
#eSound = pygame.mixer.Sound('sounds/explosion.wav')
'''enemyimg = pygame.image.load('imgs/alien.png')
eX = 400
eY = 100
eXchange = 3
eYchange = 3'''
enemyimg = []
eX = []
eY = []
eXchange = []
eYchange = []
num_of_enemies = 5
for i in range(num_of_enemies):
enemyimg.append(pygame.image.load('imgs/alien.png'))
eX.append(random.randint(100,700))
eY.append(random.randint(50,300))
eXchange.append(3)
eYchange.append(30)
def enemy(x,y,i):
screen.blit(enemyimg[i], (x,y))
#BULLET
#bSound = pygame.mixer.Sound('sounds/laser.wav')
bulletimg = pygame.image.load('imgs/bullet.png')
bX = pX
bY = pY
bYchange = -10
bState = 0 #READY
def fire_bullet(x,y):
global bState
bState = 1 #FIRE
screen.blit(bulletimg, (x+15,y-30))
#COLLISION DETECTION
def isCollision(EX,EY,BX,BY):
distance = math.sqrt( (BX-EX)**2 + (BY-EY)**2 )
if distance < 30:
return True
return False
#SCORE
score = 0
font = pygame.font.Font('freesansbold.ttf', 32)
sCoord = (10,10)
def print_score(sc):
screen.blit(font.render("SCORE: " + str(sc), True, (255,255,255)), sCoord)
#GAME OVER
def game_over_text(sc):
msg = pygame.font.Font('freesansbold.ttf', 64)
mCoord = (180,200)
screen.blit(msg.render("GAME OVER!!", True, (255,255,255)), mCoord)
fs = pygame.font.Font('freesansbold.ttf', 32)
fCoord = (280,300)
screen.blit(fs.render("FINAL SCORE: " + str(sc), True, (255,255,255)), fCoord)
running = True
while running:
#screen.fill((100,0,200))
screen.blit(background, (0,0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
sys.exit(0)
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT: pXchange -= speed
if event.key == pygame.K_RIGHT: pXchange += speed
if event.key == pygame.K_UP: pYchange -= speed
if event.key == pygame.K_DOWN: pYchange += speed
if event.key == pygame.K_SPACE:
#bSound.play()
bX,bY = pX, pY
fire_bullet(bX,bY)
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
pXchange = 0
if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
pYchange = 0
'''
collision = isCollision(eX,eY,bX,bY)
if collision:
eSound.play()
score += 1
eX = random.randint(100,700)
eY = random.randint(50,250)
bState = 0
'''
#PLAYER MOVEMENT
pX += pXchange
pY += pYchange
if pX <= 0:
pX = 800
elif pX >= 800:
pX = 0
if pY < 0:
pY = 0
elif pY>536:
pY = 536
player(pX,pY)
#ENEMY MOVEMENT
for i in range(num_of_enemies):
#GAME OVER
if eY[i] > 400:
for j in range(num_of_enemies):
eY[j] = 800
game_over_text(score)
break
eX[i] += eXchange[i]
if eX[i] > 736:
eY[i] += 30
eXchange[i] = -eXchange[i]
if eX[i] < 0:
eY[i] += 30
eXchange[i] = -eXchange[i]
collision = isCollision(eX[i],eY[i],bX,bY)
if collision:
#eSound.play()
score += 1
eX[i] = random.randint(100,700)
eY[i] = random.randint(50,250)
bState = 0
enemy(eX[i],eY[i],i)
'''
eX += eXchange
if eX > 736:
eY += 30
eXchange = -eXchange
elif eX < 0:
eY += 30
eXchange = -eXchange
enemy(eX,eY)
'''
#BULLET MOVEMENT
if bState == 1:
fire_bullet(bX,bY)
bY += bYchange
if bY <= 0:
bState = 0
print_score(score)
pygame.display.update()
Game No. - 1: Snake Game in Python:
Snake Game in Python:
import pygame
import random,sys
pygame.init()
clock = pygame.time.Clock()
#SCREEN
screen = pygame.display.set_mode((800,600))
#CAPTION
pygame.display.set_caption("SNAKE GAME")
#SNAKE KI POSITIONS
snake_pos = [[400,300],[420,300],[440,300]]
#APPLE KI POSITION
#apple_pos = [100,100]
apple_pos = [(random.randint(100,700)//20)*20, (random.randint(100,500)//20)*20]
#SCORE
score = 0
#DIRECTIONS
step = 20
up = (0, -step)
left = (-step,0)
right = (step,0)
down = (0,step)
direction = left
#FONT
font = pygame.font.SysFont('Arial', 30)
timer = 0
running = True
while running:
screen.fill((20,150,20))
#EVENT FETCHER
for event in pygame.event.get():
#QUIT
if event.type == pygame.QUIT:
running = False
pygame.quit()
sys.exit(0)
#KEYDOWN
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
print("UP")
direction = up
if event.key == pygame.K_DOWN:
print("DOWN")
direction = down
if event.key == pygame.K_LEFT:
print("LEFT")
direction = left
if event.key == pygame.K_RIGHT:
print("RIGHT")
direction = right
#snake_pos = [[snake_pos[0][0]+direction[0], snake_pos[0][1] + direction[1]]]+snake_pos[:-1]
timer += 1
if timer == 6:
snake_pos = [[snake_pos[0][0]+direction[0], snake_pos[0][1] + direction[1]]]+snake_pos[:-1]
timer = 0
#IF SNAKE EATS APPLE
if snake_pos[0] == apple_pos:
apple_pos = [(random.randint(100,700)//20)*20, (random.randint(100,500)//20)*20]
snake_pos.append(snake_pos[-1])
score += 1
#SNAKE DEATH
for i in range(1, len(snake_pos)):
if snake_pos[0] == snake_pos[i]:
print("DEAD!")
running = False
pygame.quit()
sys.exit(0)
#VERTICAL BOUNDARY
if 800 <= snake_pos[0][0] or snake_pos[0][0] <= 0:
print("DEAD!")
running = False
pygame.quit()
sys.exit(0)
#HORIZONTAL BOUNDARY
if 0 >= snake_pos[0][1] or snake_pos[0][1] >= 600:
print("DEAD!")
running = False
pygame.quit()
sys.exit(0)
#SNAKE PRINT
for x,y in snake_pos:
pygame.draw.circle(screen, (0,0,200), (x,y), 10)
#APPLE PRINT
pygame.draw.circle(screen, (200,0,0), apple_pos, 10)
#pygame.draw.circle(screen, (0,0,200), (400,300), 10)
#pygame.draw.circle(screen, (0,0,200), (420,300), 10)
#pygame.draw.circle(screen, (0,0,200), (440,300), 10)
#SCORE PRINT
text = font.render( "SCORE: " + str(score), True, (255,255,255) )
screen.blit(text, (0,0))
clock.tick(30)
pygame.display.update()
Monday 18 January 2021
Functional Dependencies MCQ
Functional Dependencies
1. We can use the following three rules to find logically implied functional dependencies. This collection of rules is called
a) Axioms
b) Armstrong’s axioms
c) Armstrong
d) Closure
2. Which of the following is not Armstrong’s Axiom?
a) Reflexivity rule
b) Transitivity rule
c) Pseudotransitivity rule
d) Augmentation rule
3. There are two functional dependencies with the same set of attributes on the left side of the arrow:
A->BC
A->B
This can be combined as
a) A->BC
b) A->B
c) B->C
d) None of the mentioned
4. Consider a relation R(A,B,C,D,E) with the following functional dependencies:
ABC -> DE and
D -> AB
The number of superkeys of R is:
a) 2
b) 7
c) 10
d) 12
5. Suppose relation R(A,B,C,D,E) has the following functional dependencies:
A -> B
B -> C
BC -> A
A -> D
E -> A
D -> E
Which of the following is not a key?
a) A
b) E
c) B, C
d) D
Let R= (A, B, C, D, E, F) be a relation scheme with the following dependencies: C->F, E->A, EC->D, A->B. Which of the following is a key for R?
A.) CD
B.) EC
C.) AE
D.) AC
Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional dependencies hold: {A–>B, BC–>D, E–>C, D–>A}. What are the candidate keys of R?
A). AE, BE
B). AE, BE, DE
C). AEH, BEH, BCH
D). AEH, BEH, DEH
Relation R has eight attributes ABCDEFGH. Fields of R contain only atomic values.
F={CH->G, A->BC, B->CFH, E->A, F- >EG} is a set of functional dependencies (FDs) so that F + is exactly the set of FDs that hold for R. How many candidate keys does the relation R have?
A.) 3
B.) 4
C.) 5
D.) 6
Consider the relation scheme R=(E,F,G,H,I,J,K,L,M,N) and the set of functional dependencies
{{E,F}→{G},{F}→{I,J},{E,H}→{K,L},{K}→ {M},{L}→{N}} on R. What is the key for R?
A.) {E,F}
B.) {E,F,H}
C.) {E,F,H,K,L}
D.) {E}
If a functional dependency set F is {A→B, BC→E, ED→A, EF→G, E→F}, find the closure of attribute set (AC)
A.) {A,B,C,E,F,G}
B.) {A,B,C,D,E,F,G}
C.) {A,B,C,D,E,F}
D.) {A,B,C,D,E,G}
A relation R(ABC) is having the following 4 tuples: (1,2,3), (4,2,3), (5,3,3) and (2,4,4). Which of the following dependency can you infer doesn't hold over relation R?
A.) A→B
B.) AB→C
C.) B→C
D.) C→B
Sunday 17 January 2021
17 Jan 2021 Test Result
17 Jan 2021 Test Result
S. No. |
Name |
Marks |
1 |
Shubham Bhardwaj |
35 |
2 |
Salvi Vatsa |
33 |
3 |
Chirag Kashyap |
30 |
4 |
Rohit Kumar |
29 |
5 |
Priyanka Yadav |
28 |
6 |
Priyanka Arora |
28 |
7 |
Manish Kumar Garg |
28 |
8 |
Vipin Kumar |
28 |
9 |
Shehbaz |
28 |
10 |
Vibhakar |
27 |
11 |
Sanjay |
27 |
12 |
Gopal Sharma |
27 |
13 |
Akshay Sharma |
27 |
14 |
Md Tehran |
26 |
15 |
Ranjeet Yadav |
26 |
16 |
Annu |
25 |
17 |
Mukesh Roy |
25 |
18 |
Lovely |
24 |
19 |
Rajesh Kumar |
24 |
20 |
Satyam |
24 |
21 |
Piyush Kumar |
23 |
22 |
Jitender |
22 |
23 |
Poonam Yadav |
21 |
24 |
Ankit Pandey |
21 |
25 |
Sandeep Kumar |
20 |
26 |
Anuj Kashyap |
20 |
27 |
Pritam Kumari |
19 |
28 |
Priya Chaurasia |
19 |
29 |
Sanjeev |
19 |
30 |
Himanshu |
19 |
31 |
Sonika Beniwal |
18 |
32 |
Raj |
18 |
33 |
Richa Dubey |
18 |
34 |
Rakesh |
18 |
35 |
Hitesh Kumar |
18 |
36 |
Nisha |
18 |
37 |
Gaurav Gahlot |
17 |
38 |
Lalit Gupta |
17 |
39 |
Sunaina Bizenia |
16 |
40 |
Chandan |
16 |
41 |
Shahib |
16 |
42 |
Dilip Gupta |
16 |
43 |
Ajay Gupta |
16 |
44 |
Ajay Kumar |
16 |
45 |
Pragati |
15 |
46 |
Akanksha Sharma |
14 |
47 |
Janisar Akhter |
14 |
48 |
Anil Yadav |
14 |
49 |
Priyanka Soni |
13 |
50 |
Meerayadav |
13 |
51 |
Shailja |
13 |
52 |
Suhail Malik |
13 |
53 |
Hemant Kumar Singh |
12 |
54 |
Sonika |
9 |
-
'''Practical No: 9: WAP in Python to create a binary file with roll_no, name and marks of the students and update the marks of...
-
List of Python with CS practical for class 12 Part – 1 Python with CS 1) WAP in Python to find the factorial of a number using fun...
-
''' Practical No: 7: WAP in Python to create a binary file with name and roll number of the students. Search for a given roll ...