Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
Python :
Concept Notes and Resources
Concept Learning Code Sheets

Hello World Printing #4871

Hello world program

Simple Print Variations #6732

Some simple variations to print() function

Exam Paper Problems

B01A #6088

( As In Exam - CBSE12A-2018 )

Differentiate between Syntax Error and Run-Time Error? Also, write a suitable

Differentiate between Syntax Error and Run-Time Error? Also, write a suitable example in Python to illustrate both.

B01A-2018 #6095

( As In Exam - CBSE12A-2018 )

Name the Python Library modules which need to be imported to invoke the foll

Name the Python Library modules which need to be imported to invoke the following functions:

(i) sin() (ii) search ()

B01C #6099

( As In Exam - CBSE12A-2018 )

Rewrite the following code in python after removing all syntax error(s). Unde

Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.

Val = int(rawinput("Value:"))
Adder = 0

for C in range(1,Val,3)
    Adder+=C
    if C%2=0:
        Print C*10
    Else:
        print C*
print Adder

B01D #6101

( As In Exam - CBSE12A-2018 )

Find and write the output of the following python code:

Data  = ["P"

Find and write the output of the following python code:

Data  = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Add   = 0
for C in range(1,6,2):
    Times= Times + C
    Alpha= Alpha + Data[C-1]+"$"
    Add = Add + Data[C]
    print Times,Add,Alpha

B01E #6105

( As In Exam - CBSE12A-2018 )

Find and write the output of the following python code:

class GRAPH:

Find and write the output of the following python code:

class GRAPH:
    def __init__(self,A=50,B=100):
        self.P1=A
        self.P2=B
    def Up(self,B):
        self.P2 = self.P2 - B
    def Down(self,B):
        self.P2 = self.P2 + 2*B
    def Left(self,A):
        self.P1 = self.P1 - A
    def Right(self,A):
        self.P1 = self.P1 + 2*A
    def Target(self):
        print "(",self.P1.":",self.P2,")"
G1=GRAPH(200,150)
G2=GRAPH()
G3=GRAPH(100)
G1.Left(10)
G2.Up(25)
G3.Down(75)
G1.Up(30)
G3.Right(15)
G1.Target()
G2.Target()
G3.Target()

B01F #6107

( As In Exam - CBSE12A-2018 )

What possible outputs(s) are expected to be displayed on screen at the time o

What possible outputs(s) are expected to be displayed on screen at the time of execution of the program from the following code? Also specify the maximum values that can be assigned to each of the variables BEGIN and LAST.

import random
POINTS=[20,40,10,30,15];
POINTS=[30,50,20,40,45];
BEGIN=random.randint(1,3)
LAST=random.randint(2,4)
for C in range(BEGIN,LAST+1):
print POINTS[C],”#”,

(i) 20#50#30#           (ii) 20#40#45#
(iii) 50#20#40#         (iv) 30#50#20#

B02A-2018 #6109

( As In Exam - CBSE12A-2018 )

What is the advantage of super() function in inheritance? Illustrate the same

What is the advantage of super() function in inheritance? Illustrate the same with the help of an example in Python.

B02B #6116

( As In Exam - CBSE12A-2018 )

class Vehicle:                        #Line 1
    Type = 'Car'            

class Vehicle:                        #Line 1
    Type = 'Car'                      #Line 2
    def __init__(self, name):         #Line 3
        self.Name = name              #Line 4
    def Show(self):                   #Line 5
        print self.Name,Vehicle.Type  #Line 6

V1=Vehicle("BMW")                     #Line 7
V1.Show()                             #Line 8
Vehicle.Type="Bus"                    #Line 9
V2=Vehicle("VOLVO")                   #Line 10
V2.Show()                             #Line 11

(i) What is the difference between the variable in Line 2 and Line 4 in the above Python code?

(ii) Write the output of the above Python code.

B02C-2018 #6120

( As In Exam - CBSE12A-2018 )

Define a class CONTAINER in Python with following specifications

Ins

Define a class CONTAINER in Python with following specifications

Instance Attributes
- Radius,Height   # Radius and Height of Container
- Type            # Type of Container
- Volume          # Volume of Container

Methods
- CalVolume()     # To calculate volume
                  # as per the Type of container
                  # With the formula as given below:
Type Formula to calculate Volume
1 3.14 * Radius * Height
3 3.14 * Radius * Height/3
- GetValue()       # To allow user to enter values of
                   # Radius, Height and Type.
                   # Also, this method should call
                   # CalVolume() to calculate Volume
- ShowContainer()  # To display Radius, Height, Type
                   # Volume of the Container

B02D #6123

( As In Exam - CBSE12A-2018 )

Answer the questions (i) to (iv) based on the following:

Class Top1(

Answer the questions (i) to (iv) based on the following:

Class Top1(object):
    def __init__(self,tx): #Line 1
        self.X=tx              #Line 2
    def ChangeX(self,tx):
        self.X=self.X+tx
    def ShowX(self):
        print self.X
Class Top2(object):
    def __init__(self,ty): #Line 3
        self.Y=ty              #Line 4
    def ChangeY(self,ty):
        self.Y=self.Y+ty
    def ShowY(self):
        print self.Y,
class Bottom(Top1,Top2):
    def __init__(self,tz): #Line 5
        self.Z = tz #Line 6
        Top2.__init__(self,2*tz) #Line 7
        Top1.__init__(self,3*tz) #Line 8
    def ChangeZ(self,tz):
        self.Z=self.Z+tz
        self.ChangeY(2*tz)
        self.ChangeX(3*tz)
    def ShowZ(self):
        print self.Z,
        self.ShowY()
        self.ShowX()
    B=Bottom(1)
    B.ChangeZ(2)
    B.ShowZ()

(i) Write the type of the inheritance illustrated in the above.

(ii) Find and write the output of the above code.

(iii) What are the methods shown in Line 1, Line 3 and Line 5 are known as?

(iv) What is the difference between the statements shown in Line 6 and Line 7?

B03A #6126

( As In Exam - CBSE12A-2018 )

Consider the following randomly ordered numbers stored in a list
786, 2

Consider the following randomly ordered numbers stored in a list
786, 234, 526, 132, 345, 467,
Show the content of list after the First, Second and Third pass of the bubble sort method used for arranging in ascending order ?
Note: Show the status of all the elements after each pass very clearly underlining the changes.

B03B-2018 #6128

( As In Exam - CBSE12A-2018 )

Write definition of a method ZeroEnding(SCORES) to add all those values in th

Write definition of a method ZeroEnding(SCORES) to add all those values in the list of SCORES, which are ending with zero (0) and display the sum.
For example,
If the SCORES contain [200,456,300,100,234,678]
The sum should be displayed as 600

B03C-2018 #6130

( As In Exam - CBSE12A-2018 )

Write AddClient(Client) and DeleteCleint(Client) methods in python to add a n

Write AddClient(Client) and DeleteCleint(Client) methods in python to add a new Client and delete a Client from a List of Client Names, considering them to act as insert and delete operations of the queue data structure.

B03D #6133

( As In Exam - CBSE12A-2018 )

Write definition of a Method COUNTNOW(PLACES) to find and display those place

Write definition of a Method COUNTNOW(PLACES) to find and display those place
names, in which there are more than 5 characters.
For example:
If the list PLACES contains
[“DELHI”,”LONDON”,”PARIS”,”NEW YORK”,”DUBAI”]
The following should get displayed
LONDON
NEW YORK

B03E #6136

( As In Exam - CBSE12A-2018 )

Evaluate the following Postfix notation of expression:
22,11,/,5,10,*,+

Evaluate the following Postfix notation of expression:
22,11,/,5,10,*,+,12,-

B04A #6139

( As In Exam - CBSE12A-2018 )

Write a statement in Python to open a text file STORY.TXT so that new content

Write a statement in Python to open a text file STORY.TXT so that new contents can be added at the end of it.

B04B #6142

( As In Exam - CBSE12A-2018 )

Write a method in python to read lines from a text file INDIA.TXT, to find an

Write a method in python to read lines from a text file INDIA.TXT, to find and display the occurrence of the word “India”.
For example:
If the content of the file is

“India is the fastest growing economy. 
India is looking for more investments around the globe.
The whole world is looking at India as a great market. 
Most of the Indians can foresee the heights that India is
capable of reaching.”

The output should be 4

B04C #6144

( As In Exam - CBSE12A-2018 )

Considering the following definition of class MULTIPLEX, write a method in py

Considering the following definition of class MULTIPLEX, write a method in python to search and display all the content in a pickled file CINEMA.DAT, where MTYPE is matching with the value ‘Comedy’.

class MULTIPLEX:
    def __init__(self,mno,mname,mtype):
        self.MNO = mno
        self.MNAME = mname
        self.MTYPE = mtype
    def Show(self):
        print self.MNO:"*",self.MNAME,"$",self.MTYPE

B01A-2017 #6211

( As In Exam - CBSE12A-2017 )

Which of the following can be used as valid variable identifier(s) in Python?

Which of the following can be used as valid variable identifier(s) in Python?
(i) 4thSum
(ii) Total
(iii) Number#
(iv) Data

B01B-2017 #6214

( As In Exam - CBSE12A-2017 )

Name the Python Library modules which need to be imported to invoke the follo

Name the Python Library modules which need to be imported to invoke the following functions
(i) floor()
(ii) randint()

B01C-2017 #6216

( As In Exam - CBSE12A-2017 )

Rewrite the following code in python after removing all syntax error(s). Unde

Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.

STRING=""WELCOME
NOTE""
for S in range[0,8]:
    print STRING(S)
print S+STRING

B01D-2017 #6218

( As In Exam - CBSE12A-2017 )

Find and write the output of the following python code:

TXT   = ["20

Find and write the output of the following python code:

TXT   = ["20","50","30","40"]
CNT   = 3
TOTAL = 0
for C in [7,5,4,6]:
    T = TXT[CNT]
    TOTAL = float (T) + C
    print TOTAL
    CNT-=1

B01E-2017 #6221

( As In Exam - CBSE12A-2017 )

Find and write the output of the following python code:

class INVENT

Find and write the output of the following python code:

class INVENTORY:
    def __init__(self,C=101,N="Pad",Q=100): #constructor
        self.Code=C
        self.IName=N
        self.Qty=int(Q);
    def Procure(self,Q):
        self.Qty = self.Qty + Q
    def Issue(self,Q):
        self.Qty -= Q
    def Status(self):
        print self.Code,":",self.IName,"#",self.Qty
I1=INVENTORY()
I2=INVENTORY(105,"Thumb Pin",50)
I3=INVENTORY(102,"U Clip")
I1.Procure(25)
I2.Issue(15)
I3.Procure(50)
I1.Status()
I3.Status()
I2.Status()

B01F-2017 #6223

( As In Exam - CBSE12A-2017 )

What are the possible outcome(s) executed from the following code? Also
sp

What are the possible outcome(s) executed from the following code? Also
specify the maximum and minimum values that can be assigned to variable N.
import random
NAV = ["LEFT","FRONT","RIGHT","BACK"];
NUM = random.randint(1,3)
NAVG = ""
for C in range(NUM,1,-1):
    NAVG = NAVG+NAV[I]
print NAVG
(i) BACKRIGHT (ii) BACKRIGHTFRONT
(iii) BACK (iv) LEFTFRONTRIGHT

B02A-2017 #6226

( As In Exam - CBSE12A-2017 )

List four characteristics of Object Oriented programming.

List four characteristics of Object Oriented programming.

B02B-2017 #6229

( As In Exam - CBSE12A-2017 )

class Exam:
   Regno=1
   Marks=75
   def __init__(self,r,m): #function 

class Exam:
   Regno=1
   Marks=75
   def __init__(self,r,m): #function 1
       self.Regno=r
       self.Marks=m
   def Assign(self,r,m): #function 2
       Regno = r
       Marks = m
   def Check(self): #function 3
       print self.Regno, self.Marks
       print Regno, Marks

(i) In the above class definition, both the functions – function 1 as well
as function 2 have similar definition. How are they different in execution?
(ii) Write statements to execute function 1 and function 2.

B02C-2017 #6231

( As In Exam - CBSE12A-2017 )

Define a class BOX in Python with following specifications

Instance 

Define a class BOX in Python with following specifications

Instance Attributes
- BoxID   # Numeric value with a default value 101
- Side   # Numeric value with a default value 10
- Area   # Numeric value with a default value 0
Methods:
- ExecArea() # Method to calculate Area as
             # Side * Side
- NewBox() # Method to allow user to enter values of
           # BoxID and Side. It should also
           # Call ExecArea Method
- ViewBox() # Method to display all the Attributes

B02D-2017 #6236

( As In Exam - CBSE12A-2017 )

Differentiate between static and dynamic binding in Python? Give suitable ex

Differentiate between static and dynamic binding in Python? Give suitable examples of each.

B02E-2017 #6238

( As In Exam - CBSE12A-2017 )

Write two methods in python using concept of Function Overloading (Polymorph

Write two methods in python using concept of Function Overloading (Polymorphism) to perform the following operations:
(i) A function having one argument as Radius, to calculate Area of Circle as 3.14#Radius#Radius
(ii) A function having two arguments as Base and Height, to calculate Area of right angled triangle as 0.5#Base#Height .

B03A-2017 #6240

( As In Exam - CBSE12A-2017 )

What will be the status of the following list after the First, Second and Thi

What will be the status of the following list after the First, Second and Third pass of the bubble sort method used for arranging the following elements in ascending order ?
Note: Show the status of all the elements after each pass very clearly underlining the changes.
52, 42, -10, 60, 90, 20

B03B-2017 #6244

( As In Exam - CBSE12A-2017 )

Write definition of a method EvenSum(NUMBERS) to add those values in the list

Write definition of a method EvenSum(NUMBERS) to add those values in the list of NUMBERS, which are odd.

B03C-2017 #6246

( As In Exam - CBSE12A-2017 )

Write Addnew(Member) and Remove(Member) methods in python to Add a new Membe

Write Addnew(Member) and Remove(Member) methods in python to Add a new Member and Remove a Member from a List of Members, considering them to act as INSERT and DELETE operations of the data structure Queue.

B03D-2017 #6249

( As In Exam - CBSE12A-2017 )

Write definition of a Method MSEARCH(STATES) to display all the state names

Write definition of a Method MSEARCH(STATES) to display all the state names
from a list of STATES, which are starting with alphabet M.
For example:
If the list STATES contains
[“MP”,”UP”,”WB”,”TN”,”MH”,”MZ”,”DL”,”BH”,”RJ”,”HR”]
The following should get displayed
MP
MH
MZ

B03E-2017 #6253

( As In Exam - CBSE12A-2017 )

Evaluate the following Postfix notation of expression:
4,2,*,22,5,6,+,/

Evaluate the following Postfix notation of expression:
4,2,*,22,5,6,+,/,-

B04A-2017 #6256

( As In Exam - CBSE12A-2017 )

Differentiate between file modes r+ and rb+ with respect to Python.

Differentiate between file modes r+ and rb+ with respect to Python.

B04B-2017 #6258

( As In Exam - CBSE12A-2017 )

Write a method in python to read lines from a text file MYNOTES.TXT, and disp

Write a method in python to read lines from a text file MYNOTES.TXT, and display
those lines, which are starting with an alphabet ‘K’.

B04C-2017 #6260

( As In Exam - CBSE12A-2017 )

Considering the following definition of class FACTORY, write a method in Pyt

Considering the following definition of class FACTORY, write a method in Python to search and display the content in a pickled file FACTORY.DAT, where FCTID is matching with the value ‘105’.

class Factory:
    def __init__(self,FID,FNAM):
        self.FCTID = FID # FCTID Factory ID
        self.FCTNM = FNAM # FCTNM Factory Name
        self.PROD = 1000 # PROD Production
    def Display(self):
        print self.FCTID,":",self.FCTNM,":",self.PROD

B01A-2016 #6266

( As In Exam - CBSE12A-2016 )

Out of the following, find those identifiers, which can not be used for namin

Out of the following, find those identifiers, which can not be used for naming Variable or Functions in a Python program:
Total*Tax, While, class, switch,
3rdRow, finally, Column31, _Total

B01B-2016 #6268

( As In Exam - CBSE12A-2016 )

Name the Python Library modules which need to be imported to invoke the foll

Name the Python Library modules which need to be imported to invoke the following functions
(i) sqrt()
(ii) dump()

B01C-2016 #6271

( As In Exam - CBSE12A-2016 )

Rewrite the following code in python after removing all syntax error(s). Unde

Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.

for Name in [Ramesh,Suraj,Priya]
    IF Name[0]='S':
        print(Name

B01D-2016 #6274

( As In Exam - CBSE12A-2016 )

Find and write the output of the following python code:

Values=[10,2

Find and write the output of the following python code:

Values=[10,20,30,40]
for Val in Values:
    for I in range(1, Val%9):
        print(I,"*",end= "" )
    print()

B01E-2016 #6277

( As In Exam - CBSE12A-2016 )

Find and write the output of the following python code:

class Book:

Find and write the output of the following python code:

class Book:
    def __init__(self,N=100,S="Python"): #constructor
        self.Bno=N
        self.BName=S
    def Assign(self, N,S):
        self.Bno= self.Bno + N
        self.BName= S + self.BName
    def ShowVal(self):
        print(self.Bno,"#",self.BName)
s=Book()
t=Book(200)
u=Book(300,"Made Easy")
s.ShowVal()
t.ShowVal()
u.ShowVal()
s.Assign(5, "Made ")
t.Assign(15,"Easy ")
u.Assign(25,"Made Easy")
s.ShowVal()
t.ShowVal()
u.ShowVal()

B01F-2016 #6280

( As In Exam - CBSE12A-2016 )

What are the possible outcome(s) executed from the following code? Also speci

What are the possible outcome(s) executed from the following code? Also specify the maximum and minimum values that can be assigned to variable PICKER.

import random
PICKER=random.randint(0,3)
COLOR=["BLUE","PINK","GREEN","RED"];
for I in COLOR:
    for J in range(1,PICKER):
        print(I,end="")
    print()
(i) (ii) (iii) (iv)
BLUE
PINK
GREEN
RED
BLUE
BLUEPINK
BLUEPINKGREEN
BLUEPINKGREENRED
PINK
PINKGREEN
GREENRED
BLUEBLUE
PINKPINK
GREENGREEN
REDRED

B02A #6284

( As In Exam - CBSE12A-2016 )

What is the difference between Multilevel and Multiple inheritance? Give suit

What is the difference between Multilevel and Multiple inheritance? Give suitable examples to illustrate both.

B03B-2016 #6288

( As In Exam - CBSE12A-2016 )

What will be the output of the following python code considering the follow

What will be the output of the following python code considering the following set
of inputs?
AMAR
THREE
A123
1200
Also, explain the try and except used in the code.
Start=0
while True:
    try:
        Number=int(raw_input(“Enter Number”))
        break
    except ValueError:
    Start=Start+2
    print(“Reenter an integer”)
print(Start)

B02C-2016 #6290

( As In Exam - CBSE12A-2016 )

Write a class CITY in Python with following specifications

Instance 

Write a class CITY in Python with following specifications

Instance Attributes
-Ccode     # Numeric value
-CName     # String value
-Pop       # Numeric value for Population
-KM        # Numeric value
-Density   # Numeric value for Population Density
Methods:
-DenCal()  # Method to calculate Density as Pop/KM
-Record()  # Method to allow user to enter values
           Ccode,CName,Pop,KM and call DenCal() method
-View()    # Method to display all the members
           also display a message ”Highly Populated City”
           if the Density is more than 10000

B02D-2016 #6294

( As In Exam - CBSE12A-2016 )

How do we implement abstract method in python? Give an example for the same.<

How do we implement abstract method in python? Give an example for the same.

B02E #6297

( As In Exam - CBSE12A-2016 )

What is the significance of super() method? Give an example for the same.

What is the significance of super() method? Give an example for the same.

B03A-2016 #6301

( As In Exam - CBSE12A-2016 )

What will be the status of the following list after the First, Second and Thi

What will be the status of the following list after the First, Second and Third pass of the selection sort method used for arranging the following elements in descending order?
Note: Show the status of all the elements after each pass very clearly underlining the changes.
12, 14, 54, 64, 90, 24

B03B-2016 #6308

( As In Exam - CBSE12A-2016 )

For a given list of values in descending order, write a method in python to s

For a given list of values in descending order, write a method in python to search for a value with the help of Binary Search method. The method should return position of the value and should return ‐1 if the value not present in the list.

B03C-2016 #6310

( As In Exam - CBSE12A-2016 )

Write Insert(City) and Delete(City) methods in python to add City and Remove

Write Insert(City) and Delete(City) methods in python to add City and Remove City considering them to act as Insert and Delete operations of the data structure Queue.

B03D-2016 #6313

( As In Exam - CBSE12A-2016 )

Write a method in python to find and display the prime numbers between 2 to N

Write a method in python to find and display the prime numbers between 2 to N. Pass N as argument to the method.

B03E-2016 #6316

( As In Exam - CBSE12A-2016 )

Evaluate the following postfix notation of expression. Show status of stack a

Evaluate the following postfix notation of expression. Show status of stack after every operation.
12,2,/,34,20,-,+,5,+

B04A-2016 #6323

( As In Exam - CBSE12A-2016 )

Write a statement in Python to perform the following operations:
● To

Write a statement in Python to perform the following operations:
● To open a text file “MYPET.TXT” in write mode
● To open a text file “MYPET.TXT” in read mode

B04B-2016 #6325

( As In Exam - CBSE12A-2016 )

Write a method in python to write multiple line of text contents into a text

Write a method in python to write multiple line of text contents into a text file daynote.txt line.

B04C-2016 #6327

( As In Exam - CBSE12A-2016 )

Consider the following definition of class Employee, write a method in python

Consider the following definition of class Employee, write a method in python to search and display the content in a pickled file emp.dat, where Empno is matching with ‘A0005’.

class Employee:
    def __init__(self,E,NM):
        self.Empno=E
        self.EName=NM
    def Display(self):
        print(self.Empno,"-",self.EName)

B01A-2015 #6334

( As In Exam - CBSE12A-2015 )

How is __init( ) __different from __del ( )__ ?

How is __init( ) __different from __del ( )__ ?

B01B-2015 #6337

( As In Exam - CBSE12A-2015 )

Name the function/method required to
(i) check if a string contains onl

Name the function/method required to
(i) check if a string contains only alphabets
(ii) give the total length of the list.

B01C-2015 #6340

( As In Exam - CBSE12A-2015 )

Rewrite the following code in python after removing all syntax error(s). Unde

Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.

def Sum(Count) #Method to find sum
    S=0
    for I in Range(1,Count+1):
        S+=I
    RETURN S
print Sum[2] #Function Call
print Sum[5]

B01D-2015 #6342

( As In Exam - CBSE12A-2015 )

Find and write the output of the following python code :

for Name in

Find and write the output of the following python code :

for Name in ['John','Garima','Seema','Karan']:
    print Name
    if Name[0]== 'S':
        break
else :
    print 'Completed!'
print 'Weldone!'

B01E-2015 #6345

( As In Exam - CBSE12A-2015 )

Find and write the output of the following python code:

class Emp:

Find and write the output of the following python code:

class Emp:
    def __init__(self,code,nm): #constructor
        self.Code=code
        self.Name=nm
    def Manip (self) :
        self.Code=self.Code+10
        self.Name='Karan'
    def Show(self,line):
        print self.Code,self.Name,line
s=Emp(25,'Mamta')
s.Show(1)
s.Manip()
s.Show(2)
print s.Code+len(s.Name)

B01F-2015 #6347

( As In Exam - CBSE12A-2015 )

What are the possible outcome(s) executed from the following code? Also spec

What are the possible outcome(s) executed from the following code? Also specify the maximum and minimum values that can be assigned to variable COUNT.

TEXT="CBSEONLINE"
COUNT=random.randint(0,3)
C=9

while TEXT[C]!='L':
    print TEXT[C]+TEXT[COUNT]+'*',
    COUNT=COUNT+1
    C=C1
(i)         (ii)        (iii)        (iv)
EC*NB*IS*   NS*IE*LO*   ES*NE*IO*    LE*NO*ON*

B02A-2015 #6349

( As In Exam - CBSE12A-2015 )

Illustrate the concept inheritance with the help of a python code

Illustrate the concept inheritance with the help of a python code

B02B-2015 #6352

( As In Exam - CBSE12A-2015 )

What will be the output of the following python code ? Explain the try and e

What will be the output of the following python code ? Explain the try and except used in the code.

A=0
B=6
print 'One'
try:
    print 'Two'
    X=B/A
    Print 'Three'
except ZeroDivisionError:
    print B*2
    print 'Four'
except:
    print B*3
    print 'Five'

B02C-2015 #6355

( As In Exam - CBSE12A-2015 )

Write a class PHOTO in Python with following specifications:
Instance A

Write a class PHOTO in Python with following specifications:
Instance Attributes

-Pno       # Numeric value
-Category  # String value
-Exhibit   # Exhibition Gallery with String value
Methods:
-FixExhibit()  # A method to assign Exhibition
               # Gallery as per Category as
               # shown in the following table
Category Exhibit
Antique Zaveri
Modern Johnsen
Classic Terenida
Register()  # A function to allow user
            # to enter values of Pno, Category
            # and call FixExhibit() method
ViewAll{)   # A function to display all the data
            # members

B02D-2015 #6357

( As In Exam - CBSE12A-2015 )

What is operator overloading with methods? Illustrate with the help of an exa

What is operator overloading with methods? Illustrate with the help of an example using a python code.

B02E-2015 #6359

( As In Exam - CBSE12A-2015 )

Write a method in python to display the elements of list twice, if
it i

Write a method in python to display the elements of list twice, if
it is a number and display the element terminated with ‘*’ if it is
not a number.
For example, if the content of list is as follows :
MyList=[‘RAMAN’,’21’,’YOGRAJ’, ‘3’, ‘TARA’]
The output should be
RAMAN*
2121
YOGRAJ*
33
TARA*

B03A-2015 #6362

( As In Exam - CBSE12A-2015 )

What will be the status of the following list after fourth pass of bubble so

What will be the status of the following list after fourth pass of bubble sort and fourth pass of selection sort used for arranging the following elements in descending order ?
34,6,12,3,45,25

B03B-2015 #6364

( As In Exam - CBSE12A-2015 )

Write a method in python to search for a value in a given list (assuming tha

Write a method in python to search for a value in a given list (assuming that the elements in list are in ascending order) with the help of Binary Search method. The method should return -1, if the value not present else it should return position of the value present in the list.

B03C-2015 #6369

( As In Exam - CBSE12A-2015 )

Write PUSH (Names) and POP (Names) methods in python to add Names and Remove

Write PUSH (Names) and POP (Names) methods in python to add Names and Remove names considering them to act as Push and Pop operations of Stack.

B03D-2015 #6372

( As In Exam - CBSE12A-2015 )

Write a method in python to find and display the composite numbers between 2

Write a method in python to find and display the composite numbers between 2 to N. Pass N as argument to the method.

B03E-2015 #6375

( As In Exam - CBSE12A-2015 )

Evaluate the following postfix notation of expression. Show status of stack

Evaluate the following postfix notation of expression. Show status of stack after every operation.
34,23,+,4,5,*,-

B04A-2015 #6378

( As In Exam - CBSE12A-2015 )

Differentiate between the following:
(i) f = open (‘diary. txt

Differentiate between the following:
(i) f = open (‘diary. txt’, ‘a’)
(ii) f = open (‘diary. txt’, ‘w’)

B04B-2015 #6380

( As In Exam - CBSE12A-2015 )

Write a method in python to read the content from a text file story.txt line

Write a method in python to read the content from a text file story.txt line by line and display the same on screen.

B04C-2015 #6382

( As In Exam - CBSE12A-2015 )

Consider the following definition of class Student. Write a method in python

Consider the following definition of class Student. Write a method in python to write the content in a pickled file student.dat

class Student:
    def_init_(self,A,N} :
        self.Admno=A
        self.Name=N
    def Show(self}:
        print (self.Admno, "#" , self.Name}

B01A-2017D #6389

( As In Exam - CBSE12D-2017 )

Which of the following can be used as valid variable identifier(s) in Python<

Which of the following can be used as valid variable identifier(s) in Python
(i) total
(ii) 7Salute
(iii) Que$tion
(iv) global

B01B-2017D #6392

( As In Exam - CBSE12D-2017 )

Name the Python Library modules which need to be imported to invoke the

Name the Python Library modules which need to be imported to invoke the
following functions
(i) ceil()       (ii) randint()

B01C-2017D #6394

( As In Exam - CBSE12D-2017 )

Rewrite the following code in python after removing all syntax error(s). Unde

Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code

TEXT=""GREAT
DAY""
for T in range[0,7]:
    print TEXT(T)
print T+TEXT

B01D-2017D #6397

( As In Exam - CBSE12D-2017 )

Find and write the output of the following Python code:

STR = ["90",

Find and write the output of the following Python code:

STR = ["90","10","30","40"]
COUNT = 3
SUM = 0
for I in [1,2,5,4]:
    S = STR[COUNT]
    SUM = float (S)+I
    print SUM
    COUNT-=1

B01E-2017 #6400

( As In Exam - CBSE12D-2017 )

Find and write the output of the following python code:

class ITEM:

Find and write the output of the following python code:

class ITEM:
    def __init__(self,I=101,N="Pen",Q=10): #constructor
        self.Ino=I
        self.IName=N
        self.Qty=int(Q);
    def Buy(self,Q):
        self.Qty = self.Qty + Q
    def Sell(self,Q):
        self.Qty -= Q
    def ShowStock(self):
        print self.Ino,":",self.IName,"#",self.Qty
I1=ITEM()
I2=ITEM(100,"Eraser",100)
I3=ITEM(102,"Sharpener")
I1.Buy(10)
I2.Sell(25)
I3.Buy(75)
I3.ShowStock()
I1.ShowStock()
I2.ShowStock()

B01F-2017 #6402

( As In Exam - CBSE12D-2017 )

What are the possible outcome(s) executed from the following code? Also speci

What are the possible outcome(s) executed from the following code? Also specify the maximum and minimum values that can be assigned to variable N. import random

SIDES=["EAST","WEST","NORTH","SOUTH"];
N=random.randint(1,3)
OUT=""
for I in range(N,1,-1):
    OUT=OUT+SIDES[I]
print OUT
(i) SOUTHNORTH   (ii) SOUTHNORTHWEST
(iii) SOUTH      (iv) EASTWESTNORTH

B02A-2017D #6404

( As In Exam - CBSE12D-2017 )

List four characteristics of Object Oriented programming.

List four characteristics of Object Oriented programming.

B02B-2017D #6407

( As In Exam - CBSE12D-2017 )

class Test:
    rollno=1
    marks=75
    def __init__(self,r,m): #funct

class Test:
    rollno=1
    marks=75
    def __init__(self,r,m): #function 1
        self.rollno=r
        self.marks=m
    def assign(self,r,m): #function 2
        rollno = n
        marks = m
    def check(self): #function 3
        print self.rollno,self.marks
    print rollno,marks

(i) In the above class definition, both the functions – function 1 as well as function
2 have similar definition. How are they different in execution?
(ii) Write statements to execute function 1 and function 2.

B02C-2017D #6409

( As In Exam - CBSE12D-2017 )

Define a class RING in Python with following specifications

Define a class RING in Python with following specifications

Instance Attributes
- RingID  # Numeric value with a default value 101
- Radius  # Numeric value with a default value 10
- Area    # Numeric value
Methods:
- AreaCal()  # Method to calculate Area as
             # 3.14*Radius*Radius
- NewRing()  # Method to allow user to enter values of
             # RingID and Radius. It should also
             # Call AreaCal Method
- ViewRing() # Method to display all the Attributes

B02D-2017D #6411

( As In Exam - CBSE12D-2017 )

Differentiate between static and dynamic binding in Python? Give suitable ex

Differentiate between static and dynamic binding in Python? Give suitable examples of each.

B02E #6414

( As In Exam - CBSE12D-2017 )

Write two methods in Python using concept of Function Overloading (Polymorphi

Write two methods in Python using concept of Function Overloading (Polymorphism) to perform the following operations:
(i) A function having one argument as side, to calculate Area of Square as side*side
(ii) A function having two arguments as Length and Breadth, to calculate Area of Rectangle as Length*Breadth.

B03A-2017D #6416

( As In Exam - CBSE12D-2017 )

What will be the status of the following list after the First, Second and Thi

What will be the status of the following list after the First, Second and Third pass of the bubble sort method used for arranging the following elements in descending order ?
Note: Show the status of all the elements after each pass very clearly underlining the changes.
152, 104, -100, 604, 190, 204

B03B-2017D #6420

( As In Exam - CBSE12D-2017 )

Write definition of a method OddSum(NUMBERS) to add those values in the list

Write definition of a method OddSum(NUMBERS) to add those values in the list of NUMBERS, which are odd.

B03C-2017D #6422

( As In Exam - CBSE12D-2017 )

Write Addnew(Book) and Remove(Book) methods in Python to Add a new Book and 

Write Addnew(Book) and Remove(Book) methods in Python to Add a new Book and Remove a Book from a List of Books, considering them to act as PUSH and POP operations of the data structure Stack.

B03D-2017D #6427

( As In Exam - CBSE12D-2017 )

Write definition of a Method AFIND(CITIES) to display all the city names from

Write definition of a Method AFIND(CITIES) to display all the city names from a list of CITIES, which are starting with alphabet A.
For example:
If the list CITIES contains
[“AHMEDABAD”,”CHENNAI”,”NEW DELHI”,”AMRITSAR”,”AGRA”]
The following should get displayed
AHEMDABAD
AMRITSAR
AGRA

B03E-2017D #6429

( As In Exam - CBSE12D-2017 )

Evaluate the following Postfix notation of expression:
2,3,*,24,2,6,+,/

Evaluate the following Postfix notation of expression:
2,3,*,24,2,6,+,/,-

B04A-2017 #6433

( As In Exam - CBSE12D-2017 )

Differentiate between file modes r+ and w+ with respect to Python.

Differentiate between file modes r+ and w+ with respect to Python.

B04B-2017D #6435

( As In Exam - CBSE12D-2017 )

Write a method in Python to read lines from a text file DIARY.TXT, and displa

Write a method in Python to read lines from a text file DIARY.TXT, and display those lines, which are starting with an alphabet ‘P’.

B04C-2017D #6437

( As In Exam - CBSE12D-2017 )

Considering the following definition of class COMPANY, write a method in Pyth

Considering the following definition of class COMPANY, write a method in Python to search and display the content in a pickled file COMPANY.DAT, where CompID is matching with the value ‘1005’.

class Company:
    def __init__(self,CID,NAM):
        self.CompID = CID #CompID Company ID
        self.CName = NAM #CName Company Name
        self.Turnover = 1000
    def Display(self):
        print self.CompID,":",self.CName,":",self.Turnover

B01A-2016D #6443

( As In Exam - CBSE12D-2016 )

Out of the following, find those identifiers, which can not be used for namin

Out of the following, find those identifiers, which can not be used for naming Variable or Functions in a Python program:

_Cost, Price*Qty, float, Switch,
Address One, Delete, Number12, do

B01B-2016D #6446

( As In Exam - CBSE12D-2016 )

Name the Python Library modules which need to be imported to invoke the

Name the Python Library modules which need to be imported to invoke the
following functions
(i) load()
(ii) pow()

B01C-2016D #6449

( As In Exam - CBSE12D-2016 )

Rewrite the following code in python after removing all syntax error(s). Unde

Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.

for Name in [Amar, Shveta, Parag]
    IF Name[0]='S':
        print(Name)

B01D-2016D #6451

( As In Exam - CBSE12D-2016 )

Find and write the output of the following python code:

Numbers=[9,1

Find and write the output of the following python code:

Numbers=[9,18,27,36]
for Num in Numbers:
    for N in range(1, Num%8):
        print(N,"#",end= "" )
    print()

B01E-2016D #6453

( As In Exam - CBSE12D-2016 )

Find and write the output of the following python code:

class Notes:

Find and write the output of the following python code:

class Notes:
    def __init__(self,N=100,Nt="CBSE"): #constructor
        self.Nno=N
        self.NName=Nt
    def Allocate(self, N,Nt):
        self.Nno= self.Bno + N
        self.NName= Nt + self.NName
    def Show(self):
        print(self.Nno,"#",self.NName)
s=Notes()
t=Notes(200)
u=Notes(300,"Made Easy")
s.Show()
t.Show()
u.Show()
s.Allocate(4, "Made ")
t.Allocate(10,"Easy ")
u.Allocate(25,"Made Easy")
s.Show()
t.Show()
u.Show()

B01F-2016D #6456

( As In Exam - CBSE12D-2016 )

What are the possible outcome(s) executed from the following code? Also speci

What are the possible outcome(s) executed from the following code? Also specify the maximum and minimum values that can be assigned to variable PICKER.

import random
PICK=random.randint(0,3)
CITY=["DELHI","MUMBAI","CHENNAI","KOLKATA"];
for I in CITY:
    for J in range(1,PICK):
        print(I,end="")
    print()
(i) (ii)
DELHIDELHI
MUMBAIMUMBAI
CHENNAICHENNAI
KOLKATAKOLKATA
DELHI
DELHIMUMBAI
DELHIMUMBAICHENNAI
(iii) (iv)
DELHI
MUMBAI
CHENNAI
KOLKATA
DELHI
MUMBAIMUMBAI
KOLKATAKOLKATAKOLKATA

B02A-2016D #6461

( As In Exam - CBSE12D-2016 )

What is the difference between Multilevel and Multiple inheritance? Give suit

What is the difference between Multilevel and Multiple inheritance? Give suitable examples to illustrate both.

B02B-2016D #6466

( As In Exam - CBSE12D-2016 )

What will be the output of the following python code considering the followin

What will be the output of the following python code considering the following set of inputs?
JAYA
My 3 books
PICK2
2120
Also, explain the try and except used in the code.

Counter=0
while True:
    try:
        Number=int(raw_input("Give a Number"))
        break
    except ValueError:
        Counter=Counter+2
        print("Reenter Number")
        print(Counter)

B02C-2016D #6468

( As In Exam - CBSE12D-2016 )

Write a class CITY in Python with following specifications

I

Write a class CITY in Python with following specifications

Instance Attributes
- Code # Numeric value
- Name # String value
- Pop # Numeric value for Population
- KM # Numeric value
- Density # Numeric value for Population Density
Methods:
- CalDen() # Method to calculate Density as Pop/KM
- Record() # Method to allow user to enter values 
           Code,Name,Pop,KM and call CalDen() method 
- See() # Method to display all the members also display
        a message "Highly Populated Area"
        if the Density is more than 12000.

B02D-2016D #6472

( As In Exam - CBSE12D-2016 )

How do we implement abstract method in python? Give an example for the same.<

How do we implement abstract method in python? Give an example for the same.

B02E-2016D #6475

( As In Exam - CBSE12D-2016 )

What is the significance of super() method? Give an example for the same.

What is the significance of super() method? Give an example for the same.

B03A-2016D #6478

( As In Exam - CBSE12D-2016 )

What will be the status of the following list after the First, Second and Thi

What will be the status of the following list after the First, Second and Third pass of the insertion sort method used for arranging the following elements in descending order?
22, 24, 64, 34, 80, 43
Note: Show the status of all the elements after each pass very clearly underlining the changes.

B03B-2016D #6481

( As In Exam - CBSE12D-2016 )

For a given list of values in descending order, write a method in python to s

For a given list of values in descending order, write a method in python to search for a value with the help of Binary Search method. The method should return position of the value and should return ]1 if the value not present in the list.

B03C-2016D #6483

( As In Exam - CBSE12D-2016 )

Write Insert(Place) and Delete(Place) methods in python to add Place and Remo

Write Insert(Place) and Delete(Place) methods in python to add Place and Remove Place considering them to act as Insert and Delete operations of the data structure Queue.

B03D-2016D #6486

( As In Exam - CBSE12D-2016 )

Write a method in python to find and display the prime numbers between 2 to N

Write a method in python to find and display the prime numbers between 2 to N. Pass N as argument to the method.

B03E-2016D #6489

( As In Exam - CBSE12D-2016 )

Evaluate the following postfix notation of expression. Show status of stack a

Evaluate the following postfix notation of expression. Show status of stack after every operation.
22,11,/,14,10,-,+,5,-

B04A-2016D #6493

( As In Exam - CBSE12D-2016 )

Write a statement in Python to perform the following operations:

Write a statement in Python to perform the following operations:

  • To open a text file gBOOK.TXTh in read mode
  • To open a text file gBOOK.TXTh in write mode

B04B-2016D #6495

( As In Exam - CBSE12D-2016 )

Write a method in python to write multiple line of text contents into a text

Write a method in python to write multiple line of text contents into a text file myfile.txt line.

B04C-2016D #6498

( As In Exam - CBSE12D-2016 )

Consider the following definition of class Staff, write a method in python to

Consider the following definition of class Staff, write a method in python to search and display the content in a pickled file staff.dat, where Staffcode is matching with ‘S0105’.

class Staff:
    def __init__(self,S,SNM):
        self.Staffcode=S
        self.Name=SNM
    def Show(self):
        print(self.Staffcode," ",
        self.Name)

B01A-2015D #6505

( As In Exam - CBSE12D-2015 )

How is _init( ) _different from _del ( ) _ ?

How is _init( ) _different from _del ( ) _ ?

B01B-2015D #6507

( As In Exam - CBSE12D-2015 )

Name the function/method required to
(i) check if a string contains onl

Name the function/method required to
(i) check if a string contains only uppercase letters
(ii) gives the total length of the list.

B01C-2015D #6509

( As In Exam - CBSE12D-2015 )

Rewrite the following code in python after removing all syntax error(s). Und

Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.

def Tot(Number) #Method to find Total
    Sum=0
    for C in Range (l, Number+l):
        Sum+=C
RETURN Sum

print Tot[3]    #Function Calls
print Tot[6]

B01D-2015D #6511

( As In Exam - CBSE12D-2015 )

Find and write the output of the following python code :

for Name in

Find and write the output of the following python code :

for Name in ['Jayes', 'Ramya', 'Taruna','Suraj']:
    print Name
    if Name[0]== 'T':
        break
    else :
        print 'Finished!'
    print 'Got it!'

B01E-2015D #6514

( As In Exam - CBSE12D-2015 )

Find and write the output of the following python code:

class Worker

Find and write the output of the following python code:

class Worker :
    def_init_(self,id,name): #constructor
        self.ID=id
        self.NAME=name
    def Change (self) :
        self.ID=self.ID+10
        self.NAME='Harish'
    def Display(self,ROW) :
        print self.ID,self.NAME,ROW
w=Worker(55,'Fardeen')
w.Display(l)
w.Change( )
w.Display(2)
print w.ID+len(w.NAME)

B01F-2015D #6516

( As In Exam - CBSE12D-2015 )

What are the possible outcome(s) executed from the following code? Also spec

What are the possible outcome(s) executed from the following code? Also specify the maximum and minimum values that can be assigned to variable NUMBER.

STRING="CBSEONLINE"
NUMBER=random.randint(0,3)
N=9
while STRING[N]!='L':
    print STRING[N]+STRING[NUMBER]+'#',
    NUMBER=NUMBER + 1
    N=Nl
(i)         (ii)        (iii)       (iv)
ES#NE#IO#   LE#NO#ON#   NS#IE#LO#   EC#NB#IS#

B02A-2015D #6518

( As In Exam - CBSE12D-2015 )

Illustrate the concept inheritance with the help of a python code

Illustrate the concept inheritance with the help of a python code

B02B-2015D #6522

( As In Exam - CBSE12D-2015 )

What will be the output of the following python code ? Explain the try and e

What will be the output of the following python code ? Explain the try and except used in the code.

U=0
V=6
print 'First'
try:
    print 'Second'
    M=V/U
    print 'Third',M
    except ZeroDivisionError :
        print V*3
        print 'Fourth'
    except:
        print V*4
        print 'Fifth'

B02C-2015D #6525

( As In Exam - CBSE12D-2015 )

Write a class PICTURE in Python with following specifications: Instance Attr

Write a class PICTURE in Python with following specifications: Instance Attributes

- Category # String value
- Location # Exhibition Location with String value
Methods:
- FixLocation() # A method to assign Exhibition
                # Location as per Category as
                # shown in the following table
Category Location
Classic Amina
Modern Jim Plaq
Antique Ustad Khan

– Enter() # A function to allow user to enter values # Pno, Category and call FixLocation() method – SeeAll() # A function to display all the data members

B02D-2015D #6527

( As In Exam - CBSE12D-2015 )

What is operator overloading with methods? Illustrate with the help of an ex

What is operator overloading with methods? Illustrate with the help of an example using a python code.

B02E-2015D #6530

( As In Exam - CBSE12D-2015 )

Write a method in python to display the elements of list thrice if it is a n

Write a method in python to display the elements of list thrice if it is a number and display the element terminated with ‘#’ if it is not a number.

For example, if the content of list is as follows:
ThisList=['41','DROND','GIRIRAJ','13','ZARA']
414141
DROND#
GIRlRAJ#
131313
ZARA#

B03A-2015D #6533

( As In Exam - CBSE12D-2015 )

What will be the status of the following list after fourth pass of bubble so

What will be the status of the following list after fourth pass of bubble sort and fourth pass of selection sort used for arranging the following elements in descending order ?
14, 10, -12, 9, 15, 35

B03B-2015D #6536

( As In Exam - CBSE12D-2015 )

Write a method in python to search for a value in a given list (assuming tha

Write a method in python to search for a value in a given list (assuming that the elements in list are in ascending order) with the help of Binary Search method. The method should return ]1 if the value not present else it should return position of the value present in the list.

B03C-2015D #6539

( As In Exam - CBSE12D-2015 )

Write PUSH (Books) and POP (Books) methods in python to add Books and remove

Write PUSH (Books) and POP (Books) methods in python to add Books and remove Books considering them to act as Push and Pop operations of Stack.

B03D-2015D #6542

( As In Exam - CBSE12D-2015 )

Write a method in python to find and display the prime numbers between 2 to

Write a method in python to find and display the prime numbers between 2 to N. Pass N as argument to the method.

B03E-2015D #6546

( As In Exam - CBSE12D-2015 )

Evaluate the following postfix notation of expression. Show status of stack

Evaluate the following postfix notation of expression. Show status of stack after every operation.
84,62,-,14,3, *,+

B04A-2015D #6548

( As In Exam - CBSE12D-2015 )

Differentiate between the following:
(i) f = open (‘diary. txt

Differentiate between the following:
(i) f = open (‘diary. txt’, ‘r’)
(ii) f = open (‘diary. txt’, ‘w’)

B04B-2015D #6550

( As In Exam - CBSE12D-2015 )

Write a method in python to read the content from a text file diary.txt line

Write a method in python to read the content from a text file diary.txt line by line and display the same on screen.

B04C-2015D #6552

( As In Exam - CBSE12D-2015 )

Consider the following definition of class Member, write a method in python

Consider the following definition of class Member, write a method in python to write the content in a pickled file member.dat

class Member:
    def_init_(self,Mno,N) :
    self.Memno=Mno
    self.Name=N
def Show(self):
    Display (self.Memno, "#" , self.Name)

B01A-2019S #7085

( As In Exam - CBSE12A-2019 )

Write the names of any four data types available in Python.

Write the names of any four data types available in Python.

B01B-2019S #7087

( As In Exam - CBSE12A-2019 )

Name the Python Library modules which need to be imported to invoke the follo

Name the Python Library modules which need to be imported to invoke the following Function:

(i) sqrt()

(ii) start()

B01C-2019S #7089

( As In Exam - CBSE12A-2019 )

Rewrite the following code in python after removing all syntax error(s). Unde

Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.

250 = Number
WHILE Number<=1000:
  if Number=>750:
    print Number
    Number=Number+100
  else
    print Number*2
    Number=Number+50

 

B01D-2019S #7092

( As In Exam - CBSE12A-2019 )

Find and write the output of the following python code :

Msg1="WeLcO

Find and write the output of the following python code :

Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0, len(Msg2)+1):
  if Msg1[I]>="A" and Msg1[I]<="M":
    Msg3=Msg3+Msg1[I]
  elif Msg1[I]>="N" and Msg1[I]<="Z":
    Msg3=Msg3+Msg2[I]
  else:
    Msg3=Msg3+"*"
print Msg3

 

B01E-2019S #7094

( As In Exam - CBSE12A-2019 )

Find and write the output of the following python code :

def Changer

Find and write the output of the following python code :

def Changer (P,Q=10) :
  P=P/Q
  Q=P%Q
  print P, "#", Q
  return P
A=200
B=20
A=Changer(A,B)
print A, "$",B
B=Changer(B)
print A, "$", B
A=Changer(A)
print A, "$" , B

B01F-2019S #7096

( As In Exam - CBSE12A-2019 )

What possible output(s) are expected to be displayed on screen at the time of

What possible output(s) are expected to be displayed on screen at the time of execution of the program from the following code ? Also specify the minimum values that can be assigned to each of the variables BEGIN and LAST.

import random
VALUES=[10,20,30,40,50,60,70,80]
BEGIN=random.randint(1,3)
LAST=random.randint(BEGIN,4)

for I in range(BEGIN, LAST+1):
print VALUES[I],"-",
(1) 30 – 40 – 50 – (ii) 10 – 20 – 30 – 40 –
(iii) 30 – 40 – 50 – 60 – (iv) 30 – 40 – 50 – 60 – 70 –

B02A-2019S #7098

( As In Exam - CBSE12A-2019 )

Write four features of object oriented programming.

Write four features of object oriented programming.

B02B-2019S-C1 #7101

( As In Exam - CBSE12A-2019 )

class Box:                       #Line 1
  L=10                           

class Box:                       #Line 1
  L=10                           #Line 2
  TYpe="HARD"                    #Line 3
  def __init__(self, T, TL=30):  #Line 4
    self.Type = T                #Line 5
    self.L  = TL                 #Line 6
  def Disp(self):                #Line 7
     print self.Type, Box.Type   #Line 8
     print self.L,Box.L          #Line 9
B1=Box("SOFT",20)                #Line 10
B1.Disp()                        #Line 11
Box.Type="FLEXI"                 #Line 12
B2=Box("HARD")                   #Line 13
B2.Disp()                        #Line 14

Write the output of the above Python code.

B02B-2019S-C2 #7107

( As In Exam - CBSE12A-2019 )

class Target:                    #Line 1
  def __init__(self):            

class Target:                    #Line 1
  def __init__(self):            #Line 2
    self.X = 20                  #Line 3
    self.Y = 20                  #Line 4
  def Disp(self):                #Line 5
    print self.X,self.Y          #Line 6
  def __del__(self):             #Line 7
     print "Target Moved"        #Line 8
def One():                       #Line 9
  T=Target()                     #Line 10
  T.Disp()                       #Line 11
One()                            #Line 12

(i) Write are the methods/functions mentioned in Line 2 and Line 7 specifically known as ?

(ii) Mention the line number of the statement, which will call and execute the method/function shown in Line 2.

B02C-2019S #7109

( As In Exam - CBSE12A-2019 )

Define a class House in Python with the following specifications:

Inst

Define a class House in Python with the following specifications:

Instance Attributes

-Hno              #House Number

-Nor              # Number of Rooms

-Type           # Type of the House

Methods/function

-AssignType()    # To assign Type of House

# based on Number of Rooms as follows :

 

Nor Type
<=2 LIG
==3 MIG
>3 HIG

– Enter()     # To allow user to enter value of

# Hno and Nor. Also, this method should

# call Assigntype() to assign Type

– # To display Hno, Nor and Type.

B02D-2019S-C1 #7114

( As In Exam - CBSE12A-2019 )

Answer the questions(i) to (iii) based on the following:

class Furni

Answer the questions(i) to (iii) based on the following:

class Furniture(object) :             #Line 1
  def __init__(self,Q) :                   #Line 2
    self.Qty = Q 
  def GetMore(self,TQ) :                   #Line 3
    self.Qty =self.Qty+TQ
  def FRDisp(self):                        #Line 4
    print self.Qty

class Fixture(object):                     #Line 5
  def __init__(self,TQ):                   #Line 6
    self.Qty=TQ
  def GetMore (self, TQ):                  #Line 7
    self.Qty = self.Qty_TQ
  def FXDisp(self):                        #Line 8
    print self .Qty
Class Flat (Furniture, Fixture):           #Line 9
  def __init__(self, fno):                 #Line 10
    self,Fno=fno
    Q=0
    if self.Fno<100:
    Q=10
    else:
    Q=20
    Furniture.__init__(self, Q):            #Line 11
    Fixture.__init__(self,Q):               #Line 12
  def More(self,Q):                         #Line 13
    Furniture.GetMore(self,Q
    Fixture.GetMore(self,Q)
  def FLDisp(self):                         #Line 14
    print self.Fno,
    Furniture.FRDisp(Self)
    Fixture.FXDisp(self)
    Fl=FLAT(101)                            #Line 15

(i) Write the type of the inheritance illustrated in the above.
(ii) Find and write the output of the above code.
(iii) What is the difference between the statements shOwn in Line 11 and Line ?

B02D-2019S-21 #7120

( As In Exam - CBSE12A-2019 )

Define inheritance, Show brief pyth0n example of single Level, Multiplier and

Define inheritance, Show brief pyth0n example of single Level, Multiplier and m Multilevel Inheritance.

B03A-2019S-C1 #7126

( As In Exam - CBSE12A-2019 )

Consider the following randomly ordered numbers stored in a list:
106,

Consider the following randomly ordered numbers stored in a list:
106, 104, 106, 102, 105, 10
Show the content of list after the First, Second and Third pass of the Selection sort method used for arranging in ascending order.
Note : Show the status of all the elements after each pass very clearly encircling the changes.

B03A-2019S-C2 #7128

( As In Exam - CBSE12A-2019 )

Consider the following randomly ordered numbers stored in a list:

106,

Consider the following randomly ordered numbers stored in a list:

106, 104, 106, 102, 105, 107

Show the content of list after the First, Second and Thired pass of the bubble sort method used for arranging in descending order.

 

 

B03B-2019S-C1 #7130

( As In Exam - CBSE12A-2019 )

Write definition of a method/function AddOddEven(VALUES) to display sum of od

Write definition of a method/function AddOddEven(VALUES) to display sum of odd and even values separately from the list of Values.

For example:

If the VALUES contain [15,26,37,10,22,13]

The function should display

Even Sum:58

Odd Sum:65

B03B-2019S-C2 #7132

( As In Exam - CBSE12A-2019 )

Write definition of a method/function HowMany(ID,Val) to cou

Write definition of a method/function HowMany(ID,Val) to count and display number of times the values of Val is present in the list ID.

For Example:

If the ID contains [115, 122, 137, 110, 122, 113] and Val contains 122

The function should display

122 found 2 Times

B03C-2019S-C1 #7134

( As In Exam - CBSE12A-2019 )

Write QueueUp(Client) and QueueDel(Client)

Write QueueUp(Client) and QueueDel(Client) methods/functions in Python to add a new Client and delete a Client from a List of Client names, considering them to act as insert and delete operations of the Queue data Structure.

B03C-2019S-C2 #7137

( As In Exam - CBSE12A-2019 )

Write PushOn(Book) and Pop(Book) methods/fu

Write PushOn(Book) and Pop(Book) methods/functions in Python to add a new Boo and delete a Book from a List of Book titles, considering them to act as push and pop operations of the Stack data structure.

B03D-2019S-C1 #7139

( As In Exam - CBSE12A-2019 )

Write a python method/function Swapper(Numbers) to swap the

Write a python method/function Swapper(Numbers) to swap the first half of the content of a list Numbers with second half of the content Numbers and display the swapped values.

Note: Assuming that the list has even number of values in it.

For example: if the list Numbers contains

[35, 67, 89, 23, 12, 45]

After swapping the list content should be displayed as

[23, 12, 45, 35, 67, 89]

B03D-2019S-C2 #7141

( As In Exam - CBSE12A-2019 )

Write a python method/function Count3and7(N) to find and dis

Write a python method/function Count3and7(N) to find and display the count of all those numbers which are between 1 and N,

which are either divisible by 3 or by 7.

For example :

If the value of N is 15

The sum should be displayed as 7

(as 3,6,7,9,12,14,15 in between 1 to 15 are either divisible by 3 or 7)

B03E-2019S-C1 #7143

( As In Exam - CBSE12A-2019 )

Evalute the following Postfix expression, showing the stack contents:

Evalute the following Postfix expression, showing the stack contents:

 250,45,9,/,5,+,20,*,-

B03E-2019S-C2 #7145

( As In Exam - CBSE12A-2019 )

Convert the following Infix expression to its equivalent Postfix expression,

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion:

A + B * C ^ D – E

B04A-2019S-C1 #7148

( As In Exam - CBSE12A-2019 )

Write a statement in Python to open a text file WRITEUP.TXT

Write a statement in Python to open a text file WRITEUP.TXT so that new content can be written in it .

B04A-2019S-C2 #7150

( As In Exam - CBSE12A-2019 )

Write a statement in Python to open a text file README.TXT s

Write a statement in Python to open a text file README.TXT so that existing content can be read from it.

B04B-2019S-C1 #7152

( As In Exam - CBSE12A-2019 )

Write a method/function ISTOUPCOUNT() in python to read cont

Write a method/function ISTOUPCOUNT() in python to read contents from a text file WRITER>TXT, to count and display the occurrence of the word “IS” or “TO” or “UP”.

For example:

If the content of the file is

IT IS UP TO US TO TAKE CARE OF OUR SURROUNDING. IT IS NOT POSSIBLE ONLY FOR THE GOVERNMENT TO TAKE RESPONSIBILITY

The method/function should display

Count of IS TO and UP is 6

B04B-2019S-C2 #7154

( As In Exam - CBSE12A-2019 )

Write a method/function AEDISP() in python to read lines from a text file WRI

Write a method/function AEDISP() in python to read lines from a text file WRITER.TXT, and display those lines, which are starting either with A or starting with E.

B04C-2019S-C1 #7156

( As In Exam - CBSE12A-2019 )

Considering the following definition of class STOCK, write a method/function

Considering the following definition of class STOCK, write a method/function COSTLY() in pyhton to search and display Name and Price from a pickled file STOCK.DAT, where Price of the items are more than 1000.

class Stock:
  def __init__(self, N, P):
    self.Name=N
    self.Price=P
  def Show(self) :
    print self.Name, "@", self.Price

B04C-2019S-C2 #7158

( As In Exam - CBSE12A-2019 )

Considering the following definition of class DOCTORS, write a method/functio

Considering the following definition of class DOCTORS, write a method/function SPLDOCS() in python to search and display all the content from a pickled file DOCS.DAT, where Specialisation of DOCTORS is “CARDIOLOGY”.

class DOCTORS:
def __init__(self,N,S):
  self.Name=N
  self.Specialisation=S
def Disp(self):
  print self.Name, "#", self.Specialication

 


Practice Problem
Quizzes

Concept Notes:33  Code Sheets:2  Exam Paper Problems:160  Practice Problems:4  Quizzes:48