20 Basic Python Questions
1. What is a Python object? Give an example.
2. Write a program to display the data type of a variable.
3. How do you declare an integer, float, string, and boolean in Python?
4. Write a program to add, subtract, multiply, and divide two numbers using arithmetic operators.
5. Write a program to check if a number is greater than another number using comparison operators.
6. Write a program that compares two strings using == and !=.
7. Demonstrate the use of assignment operators (=, +=, -=).
8. Write a program to show the difference between / and // operators.
9. Explain operator precedence with an example (2 + 3 * 4).
10. Write a program to evaluate an expression with parentheses and show how associativity works.
11. Write a program using an if statement to check if a number is positive.
12. Write a program using if-else to check if a number is even or odd.
13. Write a program using if-else to find the largest of two numbers.
14. Write a program using nested if to check whether a number is positive, negative, or zero.
15. Write a program using nested if to check if a number is divisible by both 2 and 3.
16. Write a program using if-else to check whether a given year is a leap year.
17. Write a program using if statement to check if a character is a vowel.
18. Write a program using nested if to classify a student’s grade (A, B, C, Fail) based on marks.
19. Write a program using if-else to find the largest of three numbers.
20. Write a program using nested if to check whether a person is eligible for voting (age ≥ 18) and classify them a