Practice Questions - Python
Practice Questions - Python
• What are the fundamental syntax rules in Python? Provide examples of correct
syntax.
• Explain the different operators in Python (arithmetic, comparison, logical, bitwise,
assignment, etc.) with examples.
• List the different data types available in Python. Provide examples of how each data
type can be used in a Python program.
• What is type conversion (type casting) in Python? Provide examples of implicit and
explicit type conversion.
• What are the key features of Python that make it a popular programming language?
• How is Python different from other programming languages like C, C++, or Java?
• What is indentation in Python, and why is it important?
• What are variables in Python? How do you declare and use them?
• Explain the difference between mutable and immutable data types in Python.
Provide examples.
• What is the purpose of comments in Python? Explain the different types of
comments with examples.
• What are Python literals? Explain different types of literals with examples.
• What is dynamic typing in Python? How does it work?
• What is the function in Python? How do you define and call a function? Provide an
example.
• What are function arguments and return values in Python? Explain the different
types of arguments (positional, keyword, default, arbitrary).
• Explain the difference between local and global variables in Python. Provide an
example.
Control Structures
• What are control structures in Python? List and explain different types of control
structures.
• How do conditional statements (if, elif, else) work in Python? Write a program to
check if a number is even or odd.
• Explain loops in Python. What are the differences between for and while loops?
• Write a Python program using a for loop to print numbers from 20 to 100.
• Explain the break and continue statements in loops. Provide examples
demonstrating their use.
• What are conditional statements in Python? Provide an example using if-elif-else.
• What is the difference between for and while loops?
• Write a Python program to print the Fibonacci sequence up to 5 terms using a loop.
• What is the use of the pass statement in Python? Provide an example.