Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

What are the basic operators in python?

Description

To see the basic operators in python3.

Process

Arithmetic operator.

Operators:

+ , - , * , / , % , ** , //

Used to perform basic arithmetic like addition, subtraction, multiplication, division.

Comparison operator.

Operators:

== , != , > , < , <= , >=

These operators compare the values on either side of them and decide the relation among them.

These are also called as relational operators.

Assignment operator.

Operators:

= , += , -= , *= , /= , %=, //=

These operators used to assigns values from right side operands to left side operand.

Logical operator.

Operators:

and Logical AND, or Logical OR, not Logical NOT.

If both the operands are true then condition becomes true.

Membership operator.

Operators:

in , not in

Python membership operators test for membership in a sequence, such as strings, lists, or tuples.

Sample Code

#get input from user
num=int(input(“enter the number:”))

#using conditional operator
if num > 1:

#using membership operator
for i in range(2,num):

#using arithmetic and assignment operator
if (num % i== 0):
print(num,”is not a prime number”)

#using arithmetic operator
print(num+2)
break
else:
print(num,”is a prime number”)
print(num-2)

Screenshots
What are the basic operators in python