You are on page 1of 21

Python Programs

Ques1- Write a program to enter a number and check if it is even or


odd.

Output:
Ques2- Write a program to enter a number and check if it is a prime
number or not.

Output:
Ques3- Write a program to accept a number from the user and
print the table of the number.

Output:
Ques4- Write a program to Fibonacci print series up to a certain
limit.

Output:
Ques5- Write a program to accept a number and display whether the
number is a palindrome or not.

Output:
Ques6- Write a program to find the sum of the digits of a number.

Output:
Ques7- Write a program to perform all the mathematical
operations of a calculator.

Output:
Ques8- Write a program to come the number of vowels in the string
given by user.

Output:
Ques9- Write a program that reads a line, then counts words and
display how many words are there in the line.

Output:
Ques10- Write a program that reads a line, then counts how many
times a substring affairs in the line and displace the account and
substring is: "is".
Ques11- Write a program to perform linear search on the given list by
user.

Output:
Ques12- Write a program to perform bubble sort.

Output:
Ques13- Write a program to calculate mean of a given list of
numbers.

Output:

Ques 14- Write a program to print the following Pattern:


5
5 4
5 4 3
5 4 3 2
5 4 3 2 1

Output:

Ques15- Calculate the given series:


(1)2 + (1 + 2)2 + (1 + 2 + 3)2 + - - - - - - - - + n

Output:

SQL Practical
Q16- Write queries for find outputs, which are based on the tables.
TABLE1: VEHICLE TABLE2: TRAVEL

i. To display CNO, CNAME, TRAVELDATE from the table TRAVEL in


descending order of CNO.

ii. To display the CNAME of all customers from the table TRAVEL who are
travelling by vehicle with code Vo1 or Vo2

iii. To display the CNO and CNAME of those customers from the table TRAVEL
who travelled between ‘2015-1231’ and ‘2015-05-01’.

iv. To display all the details from table TRAVEL for the customers, who have travel
distance more than 120 KM in ascending order of NOE

Q17. Write queries for find outputs, which are based on the tables.

TABLE1: VEHICLE TABLE2: TRAVEL


i. SELECT COUNT (*), VCODE FROM TRAVEL GROUP BY VCODE
HAVING COUNT (*) > 1;

ii. SELECT DISTINCT VCODE FROM TRAVEL:

iii. SELECT A. VCODE, CNAME, VEHICLETYPE FROM TRAVEL A, VEHICLE


B WHERE A. VCODE = B. VCODE and KM < 90;

iv. SELECT CNAME, KM*PERKM FROM TRAVEL A, VEHICLE B WHERE A.


VCODE = B. VCODE AND A. VCODE ‘V05’;

Q18. Consider the following tables SCHOOL and ADMIN and answer this question:
Give the output the following SQL queries:

TABLE1: SCHOOL TABLE2: ADMIN


i. Select Designation Count (*) From Admin Group By Designation Having Count
(*) <2;

ii. SELECT max (EXPERIENCE) FROM SCHOOL;

iii. SELECT TEACHER FROM SCHOOL WHERE EXPERIENCE >12 ORDER


BY TEACHER;

iv. SELECT COUNT (*), GENDER FROM ADMIN GROUP BY GENDER;

Q19. Consider the following tables SCHOOL and ADMIN and answer this question:

TABLE1: SCHOOL TABLE2: ADMIN


Write SQL statements for the following:
i. To display TEACHERNAME, PERIODS of all teachers whose periods are more
than 25.

ii. To display all the information from the table SCHOOL in descending order of
experience.

iii. To display DESIGNATION without duplicate entries from the table ADMIN.

iv. To display TEACHERNAME, CODE and corresponding DESIGNATION from


tables SCHOOL and ADMIN of Male teacher

Q20. Consider the following tables WORKER and PAYLEVEL:

TABLE1: WORKER TABLE2: PAYLEVEL


Write SQL commands for the following statements:
i. To display the name of all Workers in descending order of DOB.

ii. To display NAME and DESIGN of those Workers, whose PLEVEL is either P001 or

iii. To display the content of all the workers table, whose DOB is in between ‘19-JAN-
1984’ and ‘18-JAN-1987’.

iv. To add a new row with the following:


19, ‘Daya Kishore’, ‘Operator’, ‘P003′, ’19- Sep-2008’, ‘ll-Jul-1984’

Q21. Consider the following tables WORKER and PAYLEVEL:

TABLE1: WORKER TABLE2: PAYLEVEL


1. SELECT COUNT (PLEVEL), PLEVEL FROM WORKER GROUP BY PLEVEL;

2. SELECT MAX(DOB), MIN(DOJ) FROM WORKER;

3. SELECT Name PAY FROM WORKER


W,PAYLEVEL P WHERE W.LEVEL=
P.PLEVEL AND W.ECODE<13;

4. SELECT PLEVEL, PAYLEVEL


WHERE PLEVEL= “POO3”;

You might also like