PYTHON 50 QUESTION WITH ANSWERS FOR BASIC LEVEL
1. What is Python used for?
Python is a high-level programming language used for web
development, data science, automation, AI, and more.
2. Is Python case-sensitive?
Yes, Python is case-sensitive. For example, Variable and variable are
treated as different identifiers.
3. What is indentation in Python?
Indentation is the space used at the beginning of lines to define
blocks of code. It's mandatory in Python.
4. What is a data type?
A data type defines the kind of value a variable holds, such as integer,
string, or Boolean.
5. What is a comment in Python?
A comment is a line that Python ignores during execution, used to
explain the code to humans.
6. What is a function?
A function is a reusable block of code that performs a specific task.
7. What is the use of the input() function?
It allows the user to provide input to the program during runtime.
8. What is type casting?
Type casting means converting one data type into another, like
converting a string to an integer.
9. What is a constant?
A constant is a value that does not change during the program
, execution. Python does not have built-in constants, but variables can
be named in capital letters to indicate they shouldn’t change.
10. What is a module in Python?
A module is a file containing Python code that can be imported and
reused in other programs.
11. What is the difference between a list and a tuple?
A list is mutable (can be changed), while a tuple is immutable (cannot
be changed).
12. What is a loop in Python?
A loop is used to repeat a block of code multiple times until a
condition is met.
13. What is the use of break in a loop?
break is used to stop the loop even if the condition is still true.
14. What is the use of continue in a loop?
continue skips the current iteration and moves to the next one in the
loop.
15. What is the difference between for and while loops?
A for loop is used when you know how many times to repeat, while a
while loop runs based on a condition.
16. What is a string in Python?
A string is a sequence of characters enclosed in quotes.
17. What are string methods?
String methods are built-in functions that perform operations on
strings, like converting to uppercase or finding length.
18. What is a dictionary in Python?
A dictionary is a collection of key-value pairs used to store data.
19. What is the use of the len() function?
It returns the number of items in a string, list, tuple, or dictionary.