206 views
0 votes
0 votes
class A:

def_init__(s):  

self.s=s

def print():

pass

a = A('John')

a.print()

1 Answer

0 votes
0 votes

The code you have written is erroneous.

Assuming this is the correct code:

class A:
    def __init__(self, s):  
        self.s=s
    def print(self):
        pass
a = A('John')
a.print()

Since you are invoking `a`'s print() method, which has nothing but a `pass` statement, the output will be nothing.

Related questions

3 votes
3 votes
2 answers
1
Himani Srivastava asked Nov 5, 2015
6,798 views
The following code fragment: int x, y= 2, z, a; x= (y* =2) + (z= a =y); printf(“%d”, x); (a) prints 8(b) prints 6(c) prints 6 or 8 depending on the compile...
1 votes
1 votes
2 answers
2
Umang Raman asked Oct 7, 2015
1,204 views
int main (){ int a=5,b=3; printf("%d", a+++++b); // 5 +'s }Please Explain.
1 votes
1 votes
3 answers
3
ajit asked Oct 1, 2015
1,675 views
what is the output of the following c code?#include<stdio.h void main() { int index; for(index=1;index<=5;index++) { printf("%d",index); if(index==3) continue; } }a)1245b...
2 votes
2 votes
5 answers
4
debanjan sarkar asked Sep 3, 2015
6,671 views
void myfunc(int X){ if(X 0) myfunc( X ); printf("%d", X); } int main(){ myfunc(5); return 0; }0,0,1,2,3,44,3,2,1,04,3,2,1,0,00,1,2,3,4