0% found this document useful (0 votes)
23 views7 pages

Python Interview Full Notes

These Python interview preparation notes cover essential topics including Python basics, data types, control statements, functions, object-oriented programming concepts, and advanced topics like decorators and generators. Each section includes code examples to illustrate the concepts. The notes also highlight interview-focused topics such as mutability and memory management.

Uploaded by

Vinutha HN
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views7 pages

Python Interview Full Notes

These Python interview preparation notes cover essential topics including Python basics, data types, control statements, functions, object-oriented programming concepts, and advanced topics like decorators and generators. Each section includes code examples to illustrate the concepts. The notes also highlight interview-focused topics such as mutability and memory management.

Uploaded by

Vinutha HN
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Interview Preparation Notes (Full)

1. Python Basics
Definition: Python is a high-level, interpreted, object-oriented programming language. Example:

print("Hello, World!")

2. Variables & Data Types


• Variables: store data dynamically.
• Data Types: int, float, str, list, tuple, set, dict. Example:

x = 10
y = 3.14
name = "Vinutha"
print(type(y))

3. Input/Output

name = input("Enter name: ")


print("Hello", name)

4. Type Casting

x = "100"
y = int(x)
print(y + 20)

5. Operators
Arithmetic, Relational, Logical, Assignment, Bitwise, Identity, Membership Example:

a, b = 10, 5
print(a + b)
print(a > b)
print(a is b)

1
6. Strings

s = "Python"
print(s[0])
print(s[1:4])
print([Link]())

7. Lists

my_list = [1, 2, "hello", 3.5]


my_list.append(10)
print(my_list[2])

8. Tuples

t = (1, 2, 3, "Python")
print(t[1])

9. Sets

s = {1, 2, 2, 3, 4}
[Link](5)
print(s)

10. Dictionaries

d = {"name": "Vinutha", "age": 23}


print(d["name"])
d["age"] = 24

11. Arrays

import array
arr = [Link]('i', [1, 2, 3, 4])
print(arr[2])

2
12. Conditional Statements

x = 10
if x > 0:
print("Positive")
elif x == 0:
print("Zero")
else:
print("Negative")

13. Loops

for i in range(3):
print(i)
x = 1
while x <= 3:
print(x)
x += 1

14. Loop Control Statements


• break, continue, pass

for i in range(5):
if i == 2:
continue
print(i)

15. Comprehensions

nums = [x*x for x in range(5)]


s = {x for x in range(5)}
d = {x: x*x for x in range(5)}

16. Iterators & Generators

nums = [1,2,3]
it = iter(nums)
print(next(it))

def gen():

3
yield 1
yield 2
for x in gen():
print(x)

17. Functions

def greet(name):
return f"Hello {name}"
print(greet("Vinutha"))

18. Function Arguments


• Positional, Keyword, Default, args, *kwargs

def add(a, b=5): return a+b


def test(*args, **kwargs): print(args, kwargs)

19. Lambda Functions

square = lambda x: x*x


print(square(5))

20. Variable Scope (LEGB)

x = 10
def outer():
x = 5
def inner():
x = 2
print(x)
inner()
outer()

21. Recursion

def fact(n):
if n == 0: return 1
return n * fact(n-1)
print(fact(5))

4
22. Decorators

def decorator(func):
def wrapper():
print("Before")
func()
print("After")
return wrapper
@decorator
def hello():
print("Hello")
hello()

23. Closures

def outer(x):
def inner(): print(x)
return inner
f = outer(10)
f()

24. Classes & Objects

class Student:
def __init__(self, name, age):
[Link] = name
[Link] = age
s1 = Student("Vinutha", 23)
print([Link])

25. Attributes & Methods

class Car:
wheels = 4
def __init__(self, brand): [Link] = brand
def show(self): print(f"{[Link]} {[Link]}")
c = Car("BMW")
[Link]()

5
26. Constructors (init)

class Person:
def __init__(self, name): [Link] = name; print("Constructor called")
p = Person("Vinu")

27. Inheritance

class Parent: def greet(self): print("Parent")


class Child(Parent): def greet_child(self): print("Child")
c = Child(); [Link](); c.greet_child()

28. Polymorphism

class Animal: def sound(self): print("Sound")


class Dog(Animal): def sound(self): print("Bark")
Dog().sound()

29. Encapsulation

class Bank:
def __init__(self): self._balance=1000; self.__pin=1234
b=Bank(); print(b._balance)

30. Abstraction

from abc import ABC, abstractmethod


class Shape(ABC):
@abstractmethod
def area(self): pass
class Circle(Shape):
def area(self): return 3.14*5*5
print(Circle().area())

31. Magic Methods

class Book:
def __init__(self, pages): [Link] = pages

6
def __add__(self, other): return [Link] + [Link]
print(Book(100)+Book(200))

32. Instance, Class, Static Methods

class Demo:
company = "Python Inc"
def instance_method(self): print("Instance")
@classmethod
def class_method(cls): print([Link])
@staticmethod
def static_method(): print("Static")
Demo().instance_method(); Demo.class_method(); Demo.static_method()

33-46. Modules, Exception Handling, File


Handling
(import, try/except/finally, with, CSV/JSON)

47-55. Advanced: Iterators, Generators, Context


Managers, Memory Management, GIL, Shallow/
Deep Copy, Multithreading, Multiprocessing,
Asyncio

56-70. Interview-focused topics


(Mutability, Pass by Reference/Value, Memory Leaks, Regex, Decorators, Lambda, etc.)

End of Notes

You might also like