Professional Documents
Culture Documents
SQL:
Table: PRODUCT
Ans 1)
importmatplotlib.pyplot as plt
importnumpy as np
deffunc(x):
return [i**2+i+10 for i in x]
x = np.arange(0,10,1)
plt.plot(x,func(x))
plt.show()
Ans 2)
importmatplotlib.pyplot as plt
importnumpy as np
no_nuclear_warheads = [23,10,19]
index = np.arange(len(countries))
plt.bar(index, no_nuclear_warheads)
plt.xlabel( ' Name Of Countries ', fontsize=10)
plt.ylabel( ' Number Of Nuclear Warheads ', fontsize=10)
plt.xticks( index, countries, fontsize=10, rotation=30)
plt.title( ' NUCLEAR WARHEAD PER COUNTRY ' )
plt.show()
Ans 5)
from sys import maxsize
defcreateStack():
stack = []
return stack
defisEmpty(stack):
returnlen(stack) == 0
def pop(stack):
if (isEmpty(stack)):
returnstr(-maxsize -1)
returnstack.pop()
def peek(stack):
if (isEmpty(stack)):
returnstr(-maxsize -1)
return stack[len(stack) - 1]
stack = createStack()
push(stack, str(10))
push(stack, str(20))
push(stack, str(30))
print(pop(stack) + " popped from stack")
9.
def bubbleSort(arr):
n = len(arr)
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1] :
arr[j], arr[j+1] = arr[j+1], arr[j]
lst = []
for i in range(0, 10):
ele = int(input())
lst.append(ele)
bubbleSort(lst)
10.
str=str(input('Enter a random string:'))
sum=0
count=0
for i in range(0,len(str)):
if str[i].isnumeric() == True:
sum=sum+int(str[i])
count=count+1
else:
continue
if count>0:
print("There are",count,"numbers in the string and their sum is",sum,".")
SQL
1.
2.A.
2.A.i. SELECT * FROM PRODUCT WHERE Price>50
2.A.ii. SELECT * FROM PRODUCT WHERE Price BETWEEN 50 and 100
2.A.iii. SELECT MAX(Price) FROM PRODUCT GROUP BY Manufacturer
2.A.iv. UPDATE PRODUCT SET Price=Price+10
2.A.v. SELECT Product Name FROM PRODUCT WHERE Product Name LIKE ‘F%’
2.B.
import mysql.connector
db = mysql.connector.connect(……)
cursor = db.cursor()
db.execute(“SELECT * FROM PRODUCT WHERE P_ID in {}”.format((‘FW05’,
‘BS01’)))
db.commit()
db.close()