Python Question
1. To print the highest and lowest values in the dictionary.
2. To calculate profit-loss for given Cost and Sell Price.
3. To print the first ‘n’ multiples of a given number.
4. Create a dictionary of students to store names and marks obtained in 5
subjects
5. To find the sum of squares of the first 100 natural numbers.
6. To find the sale price of an item with a given cost and discount.
7. To find average and grade for given marks.
SQL Questions:
Write SQL statement to do the following:
a) Display the names of all the products in the store.
b) Display the name and unit price of all the products in the store.
c) Display the names of all the products with unit price less than Rs.20000.
d) Display the details of all the products with unit price in the range 20000 to
30000.
e) Display the names of all products by the manufacturer “Fit Express”.
f) Display all rows sorted in descending order of unit price
Write SQL statement to do the following:
a) Display the details of those customers whose transactions are more than
20.
b) Display Customer Name and Amount of all the customers of State Bank.
c) Display the total number of customers of Union Bank.
d) Display the details of customers whose name contains ‘I’.
Write the output for the following query:
e) Select sum(Amount) from Bank;
f) Select count(*) from Bank;
1. To print the highest and lowest values in the dictionary.
num = {"A" : 50, "B" :40 , "c":60 , "d": 10}
highest = max([Link]())
lowest = min([Link]())
print("The dictionary : ", num)
print ("Highest value : ", highest)
print("Lowest value: ",lowest)
2. To calculate profit-loss for given Cost and Sell Price.
sp = float(input("Enter selling price: "))
cp = float(input("Enter cost price: "))
if cp>sp:
loss = cp-sp
print("Loss is : ",loss)
elif sp>cp:
profit = sp-cp
print("Profit is: ",profit)
else:
print("No Profit, No Loss")
3. To print first ‘n’ multiples of given number
.num = int(input("Enter a number: "))
n = int(input("Enter how many multiples to print: "))
for i in range(1, n + 1):
print(num * i)
4. Create a dictionary of students to store names and marks obtained in 5 subjects
students = {}
name = input("Enter student name: ")
m1 = int(input("Enter marks of subject 1: "))
m2 = int(input("Enter marks of subject 2: "))
m3 = int(input("Enter marks of subject 3: "))
m4 = int(input("Enter marks of subject 4: "))
m5 = int(input("Enter marks of subject 5: "))
students[name] = [m1, m2, m3, m4, m5]
print(students)
5. To find the sum of squares of the first 100 natural numbers.
sum1 = 0
for i in range (1,101):
sum1 = sum1 + (i*i)
print("Sum of squares is : ",sum1)
[Link] find the sale price of an item with a given cost and discount.
cost = float(input("Enter cost price: "))
discount = float(input("Enter discount percentage: "))
discount_amt = (cost * discount) / 100
sale_price = cost - discount_amt
print(sale_price)
7. To find average and grade for given marks.
mm=int(input("Enter the maximum marks:"))
eng=int(input("Enter the marks of English:"))
acc=int(input("Enter the marks of Accountancy:"))
bs=int(input("Enter the marks of Business Studies:"))
eco=int(input("Enter the marks of Economics:"))
ip=int(input("Enter the marks of Informatics Practices:"))
tot=eng+acc+bs+eco+ip
t_mm=mm*5
per=(tot/t_mm)*100
print("Average is:",per,"%")
if per>=91 and per<=100:
gr='A1'
elif per>=81 and per<=90:
gr='A2'
elif per>=71 and per<=80:
gr='B1'
elif per>=61 and per<=70:
gr='B2'
elif per>=51 and per<=60:
gr='C1'
elif per>=41 and per<=50:
gr='C2'
elif per>=33 and per<=40:
gr='D'
else:
gr="Invalid Grade"
print("The Grade is:",gr)
MY SQL
[Link] ProductName FROM Product;
[Link] ProductName, UnitPrice FROM Product;
[Link] ProductName
FROM Product
WHERE UnitPrice < 20000;
[Link] *
FROM Product
WHERE UnitPrice BETWEEN 20000 AND 30000;
[Link] ProductName
FROM Product
WHERE Manufacturer = 'Fit Express';
[Link] *
FROM Product
ORDER BY UnitPrice DESC;
THOSE BANK SHIT
[Link] *
FROM Bank
WHERE Transactions > 20;
[Link] CustomerName, Amount
FROM Bank
WHERE BankName = 'State Bank';
[Link] COUNT(*)
FROM Bank
WHERE BankName = 'Union Bank';
[Link] *
FROM Bank
WHERE CustomerName LIKE '%I%';
[Link] displays the total amount of all the customers in the bank table
6. Displays total number of records (customers) in the Bank table.
HOW TO CREATE DATABASE N ALL.
FIRST DO
CREATE DATABASE IpExam;
USE IpExam;
FOR QUESTION 1 OF MYSQL:
CREATE TABLE Product (
ProductID INT PRIMARY KEY,
ProductName VARCHAR(50),
Manufacturer VARCHAR(50),
UnitPrice INT
);
INSERT INTO Product VALUES
(1, 'Treadmill Pro', 'Fit Express', 28000),
(2, 'Dumbbell Set', 'IronFlex', 15000),
(3, 'Exercise Bike', 'Fit Express', 22000),
(4, 'Rowing Machine', 'PowerGym', 32000),
(5, 'Yoga Mat', 'FlexFit', 5000);
FOR QUESTION 2 OF MYSQL:
CREATE TABLE Bank (
CustomerName VARCHAR(50),
BankName VARCHAR(30),
Transactions INT,
Amount INT);
INSERT INTO Bank VALUES
('RISHI', 'State Bank', 25, 50000),
('ADNAN', 'Union Bank', 18, 30000),
('ANITA', 'State Bank', 30, 70000),
('IMRAN', 'Union Bank', 22, 45000),
('RAHUL', 'HDFC Bank', 10, 20000);