Python Internals PDF
Python Internals PDF
Section 1 rememberns
1. Define tokens ?
A ] write a note on different types of tokens ?
B] list the difference between input () and raw input() ?
(OR)
2. A] List the rules for an identifiers ?
B] write the syntax for if – elif – else Construct
Section 2 learning
3. A] write a python programming to find if a student has obtained Past class , second class , first class , fail
based on the percentage using if – elif – else Construct ?
If a>=b;
else:
(OR)
4. A] read the name , age and salary of a person and display it with a appropriate message?
B] convert the following while loop into for loop using range () , and write the output ?
Program :- check = 4
While (check <= 8):
Print (check * 10)
Check += 2
Section 3 application
5. Salara as drawn a triangle but does not know it’s type she as measurement of all size and his wondering
to know weather or is an equivalent , isosceles , scalene triangle . Write a program for the same in python
to find the type of triangle using if – elif – else .
Section 4 analysis
6. A] program :- y= 2
Print(“assessment”)
b=b+2
y=y+3
B] program :- x =10
y=1
while x>y
x =x-4
y=y+3
Print(x)
(OR)
7. A] Program :- i=0
While I<5
Print(i)
i+=1
if i==3:
Break
else:
Print(“hello”)
B] program:- a=9
b=2
While i<5
if (4=5) && (9<=10):
Print (“hello”)
else:
print (“bye”)
if =2
else:
Print (“quit”)
Written test 2
Section 1 remembernce
➢ For the given tuple find the maximum and minimum element by using max () and min() function .
Print(setx)
Print(sety)
Setz=setx | set y
Print(setz)
(OR)
B] correct and rewrite the following python code
➢ list1 = [physics , chemistry , 2000,2001]
Print(list1)
delete [list(1)]
Print(list1)
➢ Using remove () method remove 2 elements from the list by writing a python code
Section 3 application
3. A] write a python program by using insert () , extend() , pop() , index() , and index() method on a list.
(OR)
B] write a python program on dictionary datatype using update() , pop () , pop item() , len() , and
clear() methods.
Section 4 analysis
➢ String_one=” sun”
String_two=” moon”
If string_one ==string_two:
Print(“born strings are equal”)
elif string_one < string_two:
print(“first string is greater than second string”)
else:
Print(“first string is less than second string”)
➢ List1=[10,40,30,40,10,10,10,40,50
List2=[“cat”,” bat ” , ” mat” , ” cat” , ”pet ”]
Print(“count of cat is = “, list2 .count(‘cat’))
Print(“count of 10 is = “, list1 .count(‘10’))
List1. Sort()
Print (list1)
List3=list1. Copy()
List3.append(70)
List3.append(85)
Print(“List3: “ ,+List3)
(OR)
➢ List1=[2,3.,7,5,10,17,12,4,1,13]
For i in list:
If i%2==0:
Print(i)
List1=[1,2,4,6]
List2.append(List1)
Print(List2)
List4=[2,3,6]
List4[0] , List[1] =List[1] , List[0]
Print(List4)
➢ Dictionary={‘A’:'computer’,’B’:'for ’,'C’:'science’}
Print(dictionary. Keys())
Print(dictionary. Items ())
salary = {“raj”:5000 , “ram”:60000,”vijay”:70000}
list1=salary.values()
Print(sum (list1)
Written test 3
Section 1 remembernce
1. List any 3 Built-in function along with an examples and write a code for the same in a program.
(OR)
2. List all function used in files and write a program using file functions
Section 2 understanding
3. A]Write a note on generator function and also write a code using the same.
(OR)
B] List the common exceptions used while handling errors
6. Analysis the given code and write the output for the same .
return n*n
sq=getsquare (10)
For i in sq:
Print(i)
If (n==0):
return
Print(n)
n=n-1
Print_till_zero(n)
Print_till_zero(8)
Program :-3 tables=[lambda x=x:x*10 for x in range (1:11)]
print (table())
(OR)
x =int(n)%2
if x==0:
else :
check(number)
i=0
sum=0
sum=sum+x
avg=sum/count
return avg
if ((number%5==0 ) and(number%7==0)):
else :
compute(number)
Skill test 1
1. Write a python program using comparison , relational , Boolean , bitwise and string operators .
(OR)
2. A] Write a python Program using if – elif - else Construct.
B] write a python program using for loop Construct.
3. Write a python program using try – except – else – finally Construct for catching exceptions
(OR)
4. A] write a python program using numpy for solving basic arithmetic in arrays.
B] write a python program using pandas using series.