{"id":3114,"date":"2022-10-26T10:38:38","date_gmt":"2022-10-26T10:38:38","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=3114"},"modified":"2022-10-26T10:38:40","modified_gmt":"2022-10-26T10:38:40","slug":"python-arithmetic-operators","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/python-arithmetic-operators\/","title":{"rendered":"Python Arithmetic Operators"},"content":{"rendered":"\n<p class=\"has-text-align-center\"><strong>Python Arithmetic Operators<\/strong><\/p>\n\n\n\n<p>Now, we are going to learn about the arithmetic operators in python. As the name suggests, arithmetic operators are the operators which are used with numbers (numerical values) to perform different mathematical operations like Addition, Subtraction, Multiplication, Division, etc&#8230; So, here are some of the arithmetic operators symbols, with their descriptions and an example to easily understand the concept.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Operator<\/td><td>Description<\/td><td>Example<\/td><\/tr><tr><td>+<\/td><td>This operator is used for addition.<\/td><td>If a = 3 and b = 5, then a + b = 8<\/td><\/tr><tr><td>&#8211;<\/td><td>This operator is used for subtraction.<\/td><td>If a = 6 and b = 4, then a \u2013 b = 2<\/td><\/tr><tr><td>*<\/td><td>This operator is used for multiplication.<\/td><td>If a = 5 and b = 7, then a*b = 35<\/td><\/tr><tr><td>\/<\/td><td>This operator is used for division.<\/td><td>If a = 15 and b = 2, then a\/b = 7.5<\/td><\/tr><tr><td>\/\/<\/td><td>This operator is used for floor division.<\/td><td>If a = 15 and b = 2, then a\/\/b= 7<\/td><\/tr><tr><td>%<\/td><td>This operator is a modulus operator, used to get the remainder after division.<\/td><td>If a = 10 and b = 2, then a%b=0<br>(As 2 divides 10)<\/td><\/tr><tr><td>**<\/td><td>This operator is an exponentiation operator, and we can calculate left operand to the power of right operand.<\/td><td>If a = 2 and b = 3, then a**b=8<br>(It is like a to the power of b)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Now, let\u2019s have a look at a simple program, to have a look at these different arithmetic operators, which help us do some different arithmetic operations, like addition, subtraction, multiplication, division, etc..<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1129\" height=\"243\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/ARITHMETIC-OPERATORS-IN-PYTHON.jpg\" alt=\"\" class=\"wp-image-3104\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/ARITHMETIC-OPERATORS-IN-PYTHON.jpg 1129w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/ARITHMETIC-OPERATORS-IN-PYTHON-300x65.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/ARITHMETIC-OPERATORS-IN-PYTHON-1024x220.jpg 1024w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/ARITHMETIC-OPERATORS-IN-PYTHON-768x165.jpg 768w\" sizes=\"auto, (max-width: 1129px) 100vw, 1129px\" \/><\/figure>\n<\/div>\n\n\n<p>As you can see, in the above program, we are taking two user input numbers, and then we are trying to perform some different arithmetic operations, like addition, subtraction, multiplication, division, etc.. Let\u2019s have a look at the output of the above program &#8211;<\/p>\n\n\n\n<p>Please enter the first number: 12<br>Please enter the second number: 2<br>Addition: 14<br>subtraction: 10<br>multiplication: 24<br>division: 6.0<br>floor division: 6<br>exponentiation: 144<br>Modulus: 0<\/p>\n\n\n\n<p>As you can see, we have the outputs for the respective operations. These are some very regular operations, which we can simply understand, and implement very easily, as and when required. Now, let\u2019s move on to understanding the other operators.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python Arithmetic Operators Now, we are going to learn about the arithmetic operators in python. As the name suggests, arithmetic operators are the operators which are used with numbers (numerical values) to perform different mathematical operations like Addition, Subtraction, Multiplication, Division, etc&#8230; So, here are some of the arithmetic operators symbols, with their descriptions and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[26,27],"class_list":{"0":"post-3114","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-python-tutorial","7":"tag-python","8":"tag-python-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=3114"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3114\/revisions"}],"predecessor-version":[{"id":3566,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3114\/revisions\/3566"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=3114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=3114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=3114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}