Professional Documents
Culture Documents
A Assignment Report On
A Assignment Report On
School
Biratnagar (Morang)
CERTIFICATE
j dd
Department of Computer Science
D.A.V- K.V.B. School, Biratnagar -13
Morang (Nepal)
CERTIFICATE
SIGNATURE OF EXAMINER
DATABASE MANAGEMENT SYSTEM
CREATE DATABASE:
USE DATABASE:
CREATE TABLE:
INSERT COMMAND:
SELECT COMMAND:
UPDATE COMMAND:
SORTING IN ASCENDING ORDER:
if a >= b:
return a
else:
return b
# Driver code
a = 2
b = 4
print(maximum(a, b))
OUTPUT: 4
2. PYTHON PROGRAM FOR SIMPLE INTEREST:
def simple_interest(p,t,r):
print('The principal is', p)
print('The time period is', t)
print('The rate of interest is',r)
si = (p * t * r)/100
# Driver code
simple_interest(8, 6, 8)
OUTPUT:
The principal is 8
The time period is 6
The rate of interest is 8
The Simple Interest is 3.84
# Driver Code
num = 5
print("Factorial of",num,"is",factorial(num))
OUTPUT:
Factorial of 5 is 120
4. PYTHON PROGRAM TO INTERCHANGE FIRST AND LAST ELEMENTS IN A
LIST:
def swapList(newList):
size = len(newList)
# Swapping
temp = newList[0]
newList[0] = newList[size - 1]
newList[size - 1] = temp
return newList
# Driver code
newList = [12, 35, 9, 56, 24]
print(swapList(newList))
OUTPUT:
[24, 35, 9, 56, 12]
OUTPUT:
not exist
OUTPUT:
[15, 14, 13, 12, 11, 10]
7. PYTHON PROGRAM TO MULTIPLY TWO MATRICES:
# take a 3x3 matrix
A = [[12, 7, 3],
[4, 5, 6],
[7, 8, 9]]
# take a 3x4 matrix
B = [[5, 8, 1, 2],
[6, 7, 3, 0],
[4, 5, 9, 1]]
# result will be 3x4
result = [[sum(a * b for a, b in zip(A_row, B_col))
for B_col in zip(*B)]
for A_row in A]
for r in result:
print(r)
OUTPUT:
[114, 160, 60, 27]
[74, 97, 73, 14]
[119, 157, 112, 23]
OUTPUT:
code practice quiz geeks
OUTPUT:
This
is
python
language
10. PYTHON PROGRAM TO FIND THE SUM OF ALL ITEMS IN A DICTIONARY:
# Function to print sum
def returnSum(myDict):
list = []
for i in myDict:
list.append(myDict[i])
final = sum(list)
return final
# Driver Function
dict = {'a': 100, 'b': 200, 'c': 300}
print("Sum :", returnSum(dict))
OUTPUT:
Sum : 600
# Driver code
dict1 = {'a': 10, 'b': 8}
dict2 = {'d': 6, 'c': 4}
OUTPUT:
Size of Tuple1: 96bytes
Size of Tuple2: 96bytes
Size of Tuple3: 80bytes
13. PYTHON PROGRAM TO ORDER TUPLES BY LIST:
# initializing list
test_list = [('Gfg', 3), ('best', 9), ('CS', 10), ('Geeks', 2)]
# printing original list
print("The original list is : " + str(test_list))
# initializing order list
ord_list = ['Geeks', 'best', 'CS', 'Gfg']
# Order Tuples by List
# Using dict() + list comprehension
temp = dict(test_list)
res = [(key, temp[key]) for key in ord_list]
# printing result
print("The ordered tuple list : " + str(res))
OUTPUT:
The original list is : [('Gfg', 3), ('best', 9), ('CS', 10),
('Geeks', 2)]
The ordered tuple list : [('Geeks', 2), ('best', 9), ('CS', 10),
('Gfg', 3)]
OUTPUT:
The original tuple : ([5, 6], [6, 7, 8, 9], [3])
The flattened tuple : (5, 6, 6, 7, 8, 9, 3)