Python - Set 1

Python Question & Answer Practice

Python Practice – Questions & Answers

Beginner Level

Q1. What is Python?

Python is a high-level, interpreted programming language.

Q2. Who created Python?

Guido van Rossum.

Q3. Print text in Python.
print("Hello World")
Q4. Python file extension.

.py

Q5. Declare a variable.
x = 10

Intermediate Level

Q6. What is list comprehension?

Compact way to create lists.

Q7. List comprehension example.
[x*x for x in range(5)]
Q8. Lambda function.
add = lambda a,b: a+b
Q9. Map function.
map(lambda x:x*2, nums)
Q10. Filter function.
filter(lambda x:x>2, nums)

Advanced Level

Q11. What is OOP?

Object-Oriented Programming.

Q12. Create a class.
class User:
    pass
Q13. Constructor.
def __init__(self,name):
    self.name=name
Q14. Inheritance.
class A(B):
    pass
Q15. Polymorphism.

Same method, different behavior.

No comments:

Post a Comment