DEV Community

Cover image for Arithmetic Operators in Python
Aswin Barath
Aswin Barath

Posted on • Edited on • Originally published at aswinbarath.me

Arithmetic Operators in Python

Operators are used to performing operations on any given data stored inside variables.

And arithmetic operators makes mathematical operations possible on operands in a program.

I know! I know! This is a basic concept! But let's make it fun!

Starting with addition and subtraction

Alt Text
Output:

Addition 9
Subtraction 8
Enter fullscreen mode Exit fullscreen mode

Now, Multiplication and Division

Alt Text
Output:

Multiplication 314.0
Division 2.0
Enter fullscreen mode Exit fullscreen mode

Special arithmetic operators

  • Floor division - //: rounds of the result to the nearest whole number.
  • Modulus - %: produces the remainder of the numbers Alt Text Output:
Floor Division 3
Modulus 1
Enter fullscreen mode Exit fullscreen mode
  • Exponentiation - ** : produces the power of given numbers Alt Text Output:
Exponentiation 0.025517964452291125
Exponentiation 37.78343433288728
Enter fullscreen mode Exit fullscreen mode

Best Resources

Who Am I?

I’m Aswin Barath, a Software Engineering Nerd who loves building Web Applications, now sharing my knowledge through Blogging during the busy time of my freelancing work life. Here’s the link to all of my socials categorized by platforms under one place: https://linktr.ee/AswinBarath

Thank you so much for reading my blog🙂.

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay