0% found this document useful (0 votes)
9 views4 pages

Concept PE

Uploaded by

usernam710
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Concept PE

Uploaded by

usernam710
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Sl Question Year Qno

1 Write a python code to check whether a given year is leap or not J 23 33


year=int(input('Enter the year'))
if(year%4==0):
print('Leap Year')
else:
print('Not a Leap Year')
2 What is the output of the following code M23 24
squares=[x**2 for x in range(1,11)]
OUTPUT
[1 4 9 16 25 36 49 64 81 100]
hint
prints 1 square to 10 square
3 Write a python script to display the given pattern M23 32
COMPUTER
COMPUTE
COMPUT
COMPU
COMP
COM
CO
C
str='COMPUTER'
l=len(str)
for ee in str:
print(str[:l])
l‐=1
4 What is the output of the following code? J22 24
str1="School"
print(str1*3)
OUTPUT
SchoolSchoolSchool
5 Write an SQL statement to modify the student table structure J22 30
by adding a new field
SQL statement
alter table student add age integer
6 What is the output of the following code J22 33
class Greeting:
def __init__(self, name):
self.__name=name
def display(self):
print("Good Morning", self.name)
obj=Greeting("Bindhu Madhavan")
obj.display()
OUTPUT
Good Morning Bindhu Madhavan
7 Write a program to get the following output M22 33
A
AB
ABC
A BCD
ABCDE

for i in range(65, 70):


for j in range(65, i+1):
print(chr(j), end = ' ')
print()
8 Write the output of the following commands A21 36ii
str="Thinking with Python"
print(str[::3]) Tnnwhyo
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
T h i n k i n g w i t h P y t h o n
‐19 ‐18 ‐17 ‐16 ‐15 ‐14 ‐13 ‐12 ‐11 ‐10 ‐9 ‐8 ‐7 ‐6 ‐5 ‐4 ‐3 ‐2 ‐1

i. print(str[::3])
T 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
T n n w h y o

ii.print(str[::‐3]) nt igkh
‐3 ‐2 ‐1 ‐3 ‐2 ‐1 ‐3 ‐2 ‐1 ‐3 ‐2 ‐1 ‐3 ‐2 ‐1 ‐3 ‐2 ‐1
h k g i t n

iii. print(str[9:13]) with


9 10 11 12
T h i n k i n g w i t h P y t h o n
9 import sqlite3 A21 38a
con=sqlite3.connect('organization.db')
cur=con.cursor()
cur.execute("select * from item")
s=cur.fetchmany(5)
print(s)
10 Write a note on Group by S20 32a
Group by helps to perform aggregate functions using a group of records
Example
Employee
ENO Name Area
1 E1 Adayar
2 E2 Kottur
3 E3 Adayar
4 E4 T Nagar
select area, count(*) from employee group by area;
b. order by
select * from employee order by name desc;

11 What will be the output of the following python program? S20 33


a="Computer"
b="Science"
x=a[:4]+b[len(b)‐3:] Compnce
a="Computer" b="Science"
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6
C o m p u t e r S c i e n c e
a[:4] b[len(b)‐3:] =>b[7‐3:] =>b[4:]
C o m p n c e
12 Write the output of the following Python programs S20 35ai
i. j=15
while (j>=10): 15 14 13 12 11 10
print(j, end = '\t') End of the loop
j=j‐1
else:
print('\nEnd of the loop')
ii. k=5 1 2 3 4
while (k<=9): 1 2 3 4 5
for i in range(1, k): 1 2 3 4 5 6
print(i, end='\t') 1 2 3 4 5 6 7
print(end='\n') 1 2 3 4 5 6 7 8
k=k+1
13 Debug the following python program to get the given output S20 36a
OUTPUT
Inside add() function x value is: 10
In main x value is: 10
Program Corrected Code
Line Given Code x=0
1 define add: def add():
2 globally x: global x
3 x=x+10
4 print("inside add() function x value is:") print("inside add() function x value is:",x)
5 add add()
6 print("In main x value is:") print("In main x value is:",x)
14 What will be the output of the given program? M20 24
str="COMPUTER SCIENCE"
a) print(str*2) COMPUTER SCIENCECOMPUTER SCIENCE
b) print(str[0:7]) COMPUTE

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
C O M P U T E R S C I E N C E
C O M P U T E

15 What will be the output of the following code M20 29

list=[3**x for x in range(5)]


OUTPUT [1, 3, 9, 27, 81]
Hint ‐ 3 power 0 to 3 power 4

16 write the output of the following program M20 33


class Hosting: OUTPUT
def __init__(self, name): Welcome to Python Programming
self.__name=name
def display(self):
print("Welcome to", self.__name)
obj=Hosting("Python Programming")
obj.display()

17 Write a program to display all 3 digit even numbers M20 35ai

for i in range(100, 1000, 2):


print(i,end='')

18 Write the output of the following program M20 35aii


i=1 OUTPUT
while(i<=6): 1
for j in range(1, i): 1 2
print(j, end='\t') 1 2 3
print(end='\n') 1 2 3 4
i+=1 1 2 3 4 5

19 Write the output of the following Python commands: 36 a


str1="Welcome to Python"
i. print(str1) Welcome to Python
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
W e l c o m e t o P y t h o n
‐17 ‐16 ‐15 ‐14 ‐13 ‐12 ‐11 ‐10 ‐9 ‐8 ‐7 ‐6 ‐5 ‐4 ‐3 ‐2 ‐1

ii. print(str1[11:17]) Python

iii. print(str1[11:17:2]) Pto

iv. print(str1[::4]) Wotyn


0 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
W e l c o m e t o P y t h o n

20 Write an SQL statement to create a table for employee having any five fields and create a M20 38
table constraint for the employee table

create table employee(eno integer, ename char(15), dob date, address char(30), area char(25), primary
key(eno, dob));

You might also like