100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
"Mastering Python Operators: A Comprehensive Guide to Arithmetic, Comparison, Logical, Assignment, and More" $8.39   Add to cart

Class notes

"Mastering Python Operators: A Comprehensive Guide to Arithmetic, Comparison, Logical, Assignment, and More"

 1 view  0 purchase
  • Course
  • Institution

Arithmetic Operators: These are used to perform arithmetic operations such as addition, subtraction, multiplication, division, and modulo. For example, the operator + is used for addition, the operator - is used for subtraction, the operator * is used for multiplication, the operator / is used for ...

[Show more]

Preview 2 out of 9  pages

  • April 30, 2023
  • 9
  • 2022/2023
  • Class notes
  • Student
  • All classes
avatar-seller
Python Operators
Operators in python are constructs in Python that instruct the interpreter
to perform a certain function; however, these are traditionally not defined
as functions; rather, they are syntactically and semantically different from
functions. Operators are used to performing operations on variables and
values according to their use.
Python language supports the following types of operators.

1. Arithmetic Operators
2. Bitwise Operators
3. Membership Operators
4. Identity Operators
5. Comparison Operators
6. Assignment Operators
7. Logical Operators
1. Arithmetic Operator
Arithmetic operators are used to performing mathematical operations

Operator Description Syntax Output

+ Addition a+b Returns sum of the operands

– Subtraction a-b Returns Difference of the operands

/ Division a/b Returns Quotient of the operands

* Multiplication a*b Returns product of the operands

** Exponentiation a**b returns exponent of a raised to the
power b

% Modulus a%b returns remainder of the division

// Floor division a//b returns a real value and ignores the
decimal part

, Let us consider an example program for carrying out the arithmetic
operations explained above.


Xa = int(input('Enter First number: '))
Xb = int(input('Enter Second number: '))
add = Xa + Xb
diff = Xa - Xb
mul = Xa * Xb
div = Xa / Xb
floor_div = Xa // Xb
power = Xa ** Xb
modulus = Xa % Xb
print('Sum of the numbers is',Xa ,'and' ,Xb ,'is :',add)
print('Difference of the numbers is ',Xa ,'and' ,Xb
,'is :',diff)
print('Product of the numbers is ' ,Xa ,'and' ,Xb ,'is :',mul)
print('Division of the numbers is ',Xa ,'and' ,Xb ,'is :',div)
print('Floor Division of the numbers is ',Xa ,'and' ,Xb
,'is :',floor_div)
print('Exponent of the numbers is ',Xa ,'and' ,Xb
,'is :',power)
print('Modulus of the numbers is ',Xa ,'and' ,Xb
,'is :',modulus)



2. Bitwise Operators
Refers to the operators working on a bit, i.e. they treat the operand as a

string of bits; for example, in bitwise operations, 5 will be considered as

0101.

The box below provides the bitwise operators in python

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller ajijnadaf. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $8.39. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

76800 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$8.39
  • (0)
  Add to cart