B01E-2016 – Computer Sir Ki Class

Login


Lost your password?

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

Login
[lwa]



Exam Questions-CBSE12A-2016-B01E #CPP#6277    siteicon   siteicon  

Problem Statement - B01E-2016

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()

Solution

TC++ #6277

Python 2.7 output Other Versions output
100 # Python
200 # Python
300 # Made Easy
105 # Made Python
215 # Easy Python
325 # Made EasyMade Easy
(100, ‘#’, ‘Python’)
(200, ‘#’, ‘Python’)
(300, ‘#’, ‘Made Easy’)
(105, ‘#’, ‘Made Python’)
(215, ‘#’, ‘Easy Python’)
(325, ‘#’, ‘Made EasyMade Easy’)


Share

CSKC| Created: 11-Jan-2019 | Updated: 11-Jan-2019|CBSE12A-2016









Back