You are on page 1of 6

Python:

1. Using Pyplot, draw the graph of y = x2 + x + 10


2. Using Pyplot, draw a bar graph with following data:
3. Using recursion make a program to find Fibonacci numbers
up to
Country Number Nuclear
nth
Warhead
US 23
India 10
South Korea 19
term.
4. Write a program to convert decimal number into binary
number with using library functions.
5. Write a program to Push and Pop a data in a Stack.
6. Write a function to check if an input number is a Prime
number and also if it is an Armstrong number
(Armstrong number is a number that is equal to the sum
of cubes of its digits. For example, 370 is an Armstrong
number: 370 = 33 + 73 + 03 )
7. Write a function Count(word) to count number of upper
& lower case letters in a word that is taken input.
8. Write a function Pal (word) to reverse of a world and
check if it is a Palindrome or not. For example if given
word is ‘DELHI’, then the output will be:
REVERSE = IHLED
It is not a palindrome.
9. Write a function BSort(list) to sort a list of 10 numbers,
which is taken as input, using Bubble sort.
10. Write a program to take input of a STRING and check
whether there is a number in it or not. If YES, print the
summation of the number.

SQL:

1. In a database, there are two tables given below:


Table: EMPLOYEE
EMPLOYEEI SALE JOBI
NAME
D S D
11000
E1 Sumit Sinha 102
00
13000
E2 Jojo Mascarenas 101
00
14000
E3 Ajay Rajpal 103
00
12500
E4 Mohit Ramnani 102
00
14500
E5 Arko Chatterjee 103
00
Table: JOB
JOBTITLE SALAR JOBI
Y D
President 200000 101
Vice President 125000 102
Administration 80000 103
Assistant
Accounting 70000 104
Manager
Accountant 65000 105
Sales Manager 80000 106

Write SQL queries for the following:


i. To display employee ids, name of employees, job ids with
correspond job titles
ii. To display names of employees, sales and corresponding
job titles who have achieved sales more than 130000.
iii. To display names and corresponding job titles of those
employees who have ‘SINHA in their names.
iv. Write SQL command to change the JOBID to 104 of the
EMPLOYEE with ID as E4 in the table ‘EMPLOYEE’

2. Consider the following table Product.

Table: PRODUCT

P_I Product Manufact Pri


D Name urer ce
TP0 Talcom LAK 40
1 Powder
FW Face ABC 45
05 Wash
BS0 Bath ABC 55
1 Soap
SH0 Shampoo XYZ 120
6
FW Face XYZ 95
12 Wash

A. Write SQL commands for the statement (i) to (v)


i. To display the details of products having price higher
than 50.
ii. To display the details of Products whose Price is in the
range of 50 to 100(Both values included).
iii. To display maximum price of product from different
manufacturers.
iv. To increase the Price of all Products by 10.
v. To display the product name(s) starting with ‘F’.

B. Write a python application to display all details of Products


whose Product ID is either FW05 or BS01
Answers
Python

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

countries = ['US','INDIA','SOUTH KOREA']

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 push(stack, item):


stack.append(item)
print(item + " pushed to stack ")

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)

print ("Sorted array is:")


for i in range(len(lst)):
    print ("%d" %lst[i])

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.

i. SELECT * FROM EMPLOYEE


ii. SELECT * FROM EMPLOYEE WHERE SALES>13000
iii. SELECT * FROM EMPLOYEE WHERE NAME LIKE ‘%Sinha%’
iv. UPDATE EMPLOYEE SET JOBID=104 WHERE EMPLOYEEID=E4

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()

You might also like