0% found this document useful (0 votes)
10 views

Python Advanced Level Questions

Python advance level questions
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Python Advanced Level Questions

Python advance level questions
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PYTHON

1. class c1:
a=1

def f1(self):
a = 2
c1.a +=1
print(c1.a, end=' ')
print(a, end=' ')

c1().f1()
c1().f1()

2 2 3 2
2. class A:
x=0
def __init__(self,a,b):
self.a = a
self.b = b
A.x +=1

def __init__(self):
A.x +=1

def displayCount(self):
print('Count %d' % A.x)

def display(self):
print('a: ',self.a,' ,b: ',self.b)

a1 = A('uday',100)
a2 = A('Kiran',200)
a3 = A()
a1.display()
a2.display()
print(A.x)

results in error as we have 2 init methods it takes second init which


has no arguments to pass
3. define one basic user defined exception with an example & raise it using try catch block
4. Explain request module usage & types of request methods we use & types of status code errors
-5
5. Status codes – 500 Internal Server Error 400 Bad Request 401 unauthorized 403 forbidden
6. Explain about access specifiers with example
7. Create a class with constructor & instantiate it
8. What are class attributes and instance attributes
9. What are static methods & instance methods?
10. What is abstraction and encapsulation
11. What is abstract classes in python
12. What is multithreading
13. How to create threads with example
# creating threads

t1 = threading.Thread(target=task1, name='t1')

t2 = threading.Thread(target=task2, name='t2')

# starting threads

t1.start()

t2.start()

# wait until all threads finish

t1.join()

t2.join()

14. What is logging – types of message events – info debug warning error critical
15. How to access the private members in the class

Class A:

__name = ‘Python’

a=A()

print(a._A__name) object._className__privatevariablename

16. What is the use of sep argument in print function


17. What is the use of Super method & explain it with overriding example

Super().method_name_ofparentclass

18. Explain about inheritance & types of inheritances with example


19. Check the code & correct if needed and print the output
for i in range(5):
if i < 10:
print(i)
else:
break
else:
print('continues')

20.

You might also like