Prepared By : Prof. Uday Shah (HOD-IT)
Python Interview Questions for Beginners
1. What is Python?
Python is a high-level, interpreted, object-oriented programming language used for web development, data science, automation, etc.
2. What are the features of Python?
-
Easy to learn
-
Interpreted
-
Object-oriented
-
Cross-platform
-
Large standard library
3. What is PEP 8?
PEP 8 is Python’s style guide used to write clean and readable code.
4. What is a variable in Python?
A variable is a named memory location used to store data.
5. What are Python data types?
-
int
-
float
-
str
-
bool
-
list
-
tuple
-
set
-
dict
6. What is the difference between list and tuple?
| List | Tuple |
|---|---|
| Mutable (can change) | Immutable (cannot change) |
Uses [] |
Uses () |
7. What is a dictionary in Python?
A dictionary stores data as key-value pairs.
Example: {"name": "Uday", "age": 25}
8. What is type casting?
Converting one data type to another.
Example: int("10")
9. What is indentation in Python?
Indentation defines blocks of code. Python uses spaces instead of { }.
10. What is a function?
A block of reusable code defined using def.
11. What is the difference between return and print?
-
returnsends a value back from a function -
printdisplays output on screen
12. What is a module?
A .py file that contains variables, functions, or classes.
13. What is a package?
A collection of modules inside a directory containing __init__.py.
14. What are keywords in Python?
Reserved words like if, else, for, while, etc.
15. What is the use of if __name__ == "__main__":?
It checks whether the file is executed directly or imported.
16. What is the difference between == and is?
-
==compares values -
iscompares memory locations
17. What is a loop?
Repeating a block of code using for or while.
18. How do you create a list in Python?
my_list = [1, 2, 3]
19. How do you create a function in Python?
def greet():
print("Hello")
20. What is a class in Python?
A class is a blueprint for creating objects.