{"id":130,"date":"2026-03-02T14:28:22","date_gmt":"2026-03-02T09:28:22","guid":{"rendered":"https:\/\/gigz.pk\/python\/?post_type=lesson&#038;p=130"},"modified":"2026-03-16T18:39:09","modified_gmt":"2026-03-16T13:39:09","slug":"mathematical-operations","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/python\/lesson\/mathematical-operations\/","title":{"rendered":"Mathematical Operations"},"content":{"rendered":"\n<p>Mathematical operations are one of the biggest advantages of using NumPy arrays. Unlike Python lists, NumPy allows you to perform calculations on entire arrays at once.<\/p>\n\n\n\n<p>This makes data analysis faster and more efficient.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Arithmetic Operations<\/h2>\n\n\n\n<p>First, import NumPy:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import numpy as np<\/pre>\n\n\n\n<p>Create an array:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr = np.array([1, 2, 3, 4])<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Addition<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">arr + 5<\/pre>\n\n\n\n<p>Adds 5 to each element.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Subtraction<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">arr - 2<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Multiplication<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">arr * 3<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Division<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">arr \/ 2<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Power<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">arr ** 2<\/pre>\n\n\n\n<p>Squares each element.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Array to Array Operations<\/h2>\n\n\n\n<p>Create another array:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr2 = np.array([10, 20, 30, 40])<\/pre>\n\n\n\n<p>Addition:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr + arr2<\/pre>\n\n\n\n<p>Multiplication:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr * arr2<\/pre>\n\n\n\n<p>Division:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arr2 \/ arr<\/pre>\n\n\n\n<p>Operations happen element-wise.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mathematical Functions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Square Root<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">np.sqrt(arr)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Exponential<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">np.exp(arr)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Logarithm<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">np.log(arr)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Absolute Value<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">np.abs(arr)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Statistical Operations<\/h2>\n\n\n\n<p>Mean:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.mean(arr)<\/pre>\n\n\n\n<p>Sum:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.sum(arr)<\/pre>\n\n\n\n<p>Minimum:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.min(arr)<\/pre>\n\n\n\n<p>Maximum:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.max(arr)<\/pre>\n\n\n\n<p>Standard Deviation:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.std(arr)<\/pre>\n\n\n\n<p>Variance:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.var(arr)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Matrix Operations (For 2D Arrays)<\/h2>\n\n\n\n<p>Create a matrix:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">matrix = np.array([[1, 2], [3, 4]])<\/pre>\n\n\n\n<p>Matrix Transpose:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">matrix.T<\/pre>\n\n\n\n<p>Matrix Multiplication:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">np.dot(matrix, matrix)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Why Mathematical Operations Matter<\/h2>\n\n\n\n<p>In Data Analytics, mathematical operations help you:<\/p>\n\n\n\n<p>Clean and transform data<br>Calculate statistics<br>Normalize values<br>Perform modeling<br>Analyze trends<\/p>\n\n\n\n<p>NumPy makes these operations fast and simple.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Key Takeaway<\/h2>\n\n\n\n<p>NumPy allows you to perform powerful mathematical and statistical operations on entire datasets efficiently. Mastering these operations is essential for Data Analytics and Data Science.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/python\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">PYTHON FOR DATA ANALYTICS (PYDA) > NumPy > Mathematical Operations<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773668019563\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p><\/p>\n","protected":false},"menu_order":67,"template":"","class_list":["post-130","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Mathematical Operations - One Language. Endless Possibilities<\/title>\n<meta name=\"description\" content=\"Master NumPy in Python: perform array calculations, statistical operations, and matrix math for fast, efficient data analysis and modeling\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/python\/lesson\/mathematical-operations\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mathematical Operations - One Language. Endless Possibilities\" \/>\n<meta property=\"og:description\" content=\"Master NumPy in Python: perform array calculations, statistical operations, and matrix math for fast, efficient data analysis and modeling\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/python\/lesson\/mathematical-operations\/\" \/>\n<meta property=\"og:site_name\" content=\"One Language. Endless Possibilities\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-16T13:39:09+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/mathematical-operations\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/mathematical-operations\\\/\",\"name\":\"Mathematical Operations - One Language. Endless Possibilities\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\"},\"datePublished\":\"2026-03-02T09:28:22+00:00\",\"dateModified\":\"2026-03-16T13:39:09+00:00\",\"description\":\"Master NumPy in Python: perform array calculations, statistical operations, and matrix math for fast, efficient data analysis and modeling\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/mathematical-operations\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/mathematical-operations\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/mathematical-operations\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PYTHON FOR DATA ANALYTICS (PYDA) > NumPy > Mathematical Operations\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\",\"name\":\"One Language. Endless Possibilities\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mathematical Operations - One Language. Endless Possibilities","description":"Master NumPy in Python: perform array calculations, statistical operations, and matrix math for fast, efficient data analysis and modeling","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/python\/lesson\/mathematical-operations\/","og_locale":"en_US","og_type":"article","og_title":"Mathematical Operations - One Language. Endless Possibilities","og_description":"Master NumPy in Python: perform array calculations, statistical operations, and matrix math for fast, efficient data analysis and modeling","og_url":"https:\/\/gigz.pk\/python\/lesson\/mathematical-operations\/","og_site_name":"One Language. Endless Possibilities","article_modified_time":"2026-03-16T13:39:09+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/python\/lesson\/mathematical-operations\/","url":"https:\/\/gigz.pk\/python\/lesson\/mathematical-operations\/","name":"Mathematical Operations - One Language. Endless Possibilities","isPartOf":{"@id":"https:\/\/gigz.pk\/python\/#website"},"datePublished":"2026-03-02T09:28:22+00:00","dateModified":"2026-03-16T13:39:09+00:00","description":"Master NumPy in Python: perform array calculations, statistical operations, and matrix math for fast, efficient data analysis and modeling","breadcrumb":{"@id":"https:\/\/gigz.pk\/python\/lesson\/mathematical-operations\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/python\/lesson\/mathematical-operations\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/python\/lesson\/mathematical-operations\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/python\/"},{"@type":"ListItem","position":2,"name":"PYTHON FOR DATA ANALYTICS (PYDA) > NumPy > Mathematical Operations"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/python\/#website","url":"https:\/\/gigz.pk\/python\/","name":"One Language. Endless Possibilities","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/media?parent=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}