0% found this document useful (0 votes)
6 views1 page

Python Operator Practice Questions

The document contains a list of Python operator practice questions designed to help users understand and apply various operators in programming. It covers arithmetic, comparison, logical, and bitwise operations, as well as concepts like operator precedence and assignment. Each question prompts the user to write code that demonstrates the functionality of different operators in Python.

Uploaded by

niharikap229
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)
6 views1 page

Python Operator Practice Questions

The document contains a list of Python operator practice questions designed to help users understand and apply various operators in programming. It covers arithmetic, comparison, logical, and bitwise operations, as well as concepts like operator precedence and assignment. Each question prompts the user to write code that demonstrates the functionality of different operators in Python.

Uploaded by

niharikap229
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
You are on page 1/ 1

Python Operator Practice Questions

1. Write a program to add, subtract, multiply, divide, and modulus two numbers entered by the user.
2. Calculate the area and perimeter of a rectangle using length and width as inputs.
3. Find the square and cube of a number using the exponent operator (**).
4. Swap two numbers using arithmetic operators (no third variable).
5. Take two numbers and display the quotient and remainder.
6. Evaluate the expression a + b * c - d / e using input values and explain operator precedence.
7. Start with x = 10. Increment x by 5, then decrement by 3, and print the final value using += and
-=.
8. Use *=, /=, and %= on a variable and print output after each step.
9. Take input from user, multiply it by 2 using assignment operator and print result.
10. Demonstrate compound assignment in a loop: increment a variable by 2 until it reaches 20.
11. Take age as input and check if the person is eligible to vote (age >= 18).
12. Compare two numbers and print whether the first is greater, smaller, or equal to the second.
13. Check if a number is between 10 and 50 using comparison operators.
14. Take a password length and verify if it is strong (length >= 8).
15. Check if two strings are equal using ==.
16. Check if a number is between 1 and 100 using and operator.
17. Write a login program: check if both username and password match using and.
18. Check if a number is divisible by 3 or 5 using or operator.
19. Check if a number is not negative using not operator.
20. Take marks in 3 subjects and check if the student passed in all using and.
21. Print the binary representation of two numbers using bin() and apply &, |, and ^ operators.
22. Left shift a number by 2 bits and right shift it by 2 bits, print both results.
23. Use bitwise NOT (~) operator on a number and explain the output.
24. Apply ^ (XOR) on two numbers and explain its behavior with examples.
25. Count number of set bits in a number using bitwise operations.
26. Check if a character is present in a string using in.
27. Check if an element is not in a list using not in.
28. Use is and == to compare two lists: a = [1, 2, 3], b = [1, 2, 3].
29. Compare two strings with is and ==, and explain the difference.
30. Write a program that checks if a user-given number exists in a predefined list.
31. Take marks from the user and use ternary operator to print “Pass” or “Fail”.
32. Take two numbers and an operator (+, -, *, /) from user input and perform the operation.
33. Find the largest of three numbers using logical and comparison operators.
34. Write a calculator program that uses all arithmetic operators based on user input.
35. Write a program to evaluate this logic: (a > b and c < d) or not e == f.

You might also like