Operators In Python

1 minute read

Python Assignment Operators

These operators are normally used to assign values to the variables.

Assignment Operators

Python Comparison Operator

Comparison operators are used to compare two values.

Comparision Operators

Python Logical Operator

Logical operators are normally used wherever there is a need to combine conditions into a single one.

Logical Operators

Python Identity Operator

Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location

Python identity operators

Python Membership Operator

Membership operators are used to test if a sequence is presented in an object

Python membership operator

Python Bitwise Operator

Bitwise operators are used to compare (binary) numbers.

bitwise operators

Let’s solve some basic programming problems,

Exercise your way out:

Q - Given an integer, n , perform the following conditional actions:

  • If n is odd, print Weird
  • If n is even and in the inclusive range of 2 to 5 , print Not Weird
  • If n is even and in the inclusive range of 6 to 20 , print Weird
  • If n is even and greater than 20 , print Not Weird

Q - eduAlgo is interested to buy a new plot of land for it’s brand new office. If the land has an area greater than 4 Sq. Kms, then the founder is going to buy that plot for the office. Create a program that calculated the area of the plot, provided the following,

  • The plot can only be circular,rectangular,square and triangular shape. The user enters the plot category.
  • Depending upon the plot category you have to take the required inputs for the area calculation from the user.
  • And if the final area is greater than 4 Sq. Kms, then print “Accepted”, else print “Not Accepted”.

Q - Given the marks of a student for five subjects, write a program to check if the student is passed or failed ! Threshold to pass the exam is 35%.

We are here to help ! Be sure to check our website and don’t hesitate to ask any questions on our community platform. We provide personal mentoring and teaching too, in order to upgrade your skills. Vist www.edualgoacademy.com to get started.

Spotted a bug ? Great job, you found a bug. Please report it to us in our mail and we’ll fix it as soon as possible.