<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tejas Magade on Medium]]></title>
        <description><![CDATA[Stories by Tejas Magade on Medium]]></description>
        <link>https://medium.com/@magadetejas?source=rss-76515ea813e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cLPexmi5o6UHEqWTKsfstA.jpeg</url>
            <title>Stories by Tejas Magade on Medium</title>
            <link>https://medium.com/@magadetejas?source=rss-76515ea813e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:24:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@magadetejas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Functions in Python: A Beginner’s guide to know about it.]]></title>
            <link>https://magadetejas.medium.com/functions-in-python-a-beginners-guide-to-know-about-it-3b4271701f76?source=rss-76515ea813e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b4271701f76</guid>
            <category><![CDATA[function-declaration]]></category>
            <category><![CDATA[functions-in-python]]></category>
            <category><![CDATA[function-definition]]></category>
            <category><![CDATA[function-in-programming]]></category>
            <category><![CDATA[calling-function]]></category>
            <dc:creator><![CDATA[Tejas Magade]]></dc:creator>
            <pubDate>Wed, 02 Dec 2020 17:06:10 GMT</pubDate>
            <atom:updated>2021-01-02T19:22:57.207Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-ZiVAHTlLly0vFeo5KZnw.png" /><figcaption>Function in Python</figcaption></figure><p>We all know how big is the function plays role in each programming language similarly, in python there is also a concept called function.</p><h4>Defn of function</h4><blockquote>A function is a group of statements that are used to perform certain tasks.</blockquote><p>Python already has some built-in functions present, some of which are as follows.<br> 1. <strong><em>print()</em></strong> — As we know the print() function in Python, we use it to show the output.<br> 2. <strong><em>sqrt()</em></strong> — Using this function, we can directly extract the square root of a value.<br> 3. <strong><em>power()</em></strong> — Using this function, we can extract the power of a value.</p><p>These and many more built-in functions are available in Python language.</p><h3>Advantages of functions</h3><p>1. Once written, we can use the code whenever we want. Therefore, functions are also called reusable code.<br>2. Code redundancy functions are avoided.<br>3. Modular programming makes programming easier.<br>4. The code makes the function easier to handle.<br>5. The use of Function reduces the length of the program.</p><p>So, now let us see how to create a function and how to use it in python. For that, we are doing two steps one is <strong>Defining a function</strong> and the other <strong>Calling a function</strong>.</p><h3>Defining a Function</h3><p>But whenever you want to use a function, first you have to tell the compiler what the function is going to do. For that, first, we define the function.</p><p>In Python, we use the keyword def to define a function. And then we add the name and parenthesis <strong><em>()</em></strong><em> </em>of our function. In Parenthesis <strong><em>()</em></strong> the parameters of your function are passed.</p><p>You will notice by looking at the following syntax.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fd44c5335b946de275602bf9e59369e/href">https://medium.com/media/9fd44c5335b946de275602bf9e59369e/href</a></iframe><p>Let us now look at a simple program.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9650539596f21a348c459cb6ebe3cf1/href">https://medium.com/media/b9650539596f21a348c459cb6ebe3cf1/href</a></iframe><p>on the above code, we are creating a function to add two values.</p><p><strong><em>def sum (a, b): </em></strong>Using the keyword <strong><em>def</em></strong>, we are telling the compiler that this is my function and I am defining it. Next to <strong><em>def</em></strong> is written <strong><em>sum()</em></strong> which denotes that the name of the function is a sum. And in the subsequent parenthesis <strong><em>()</em></strong>, two variables are passed named <strong><em>a</em></strong> and <strong><em>b</em></strong>. After parenthesis, we have used a colon <strong><em>:</em></strong> which means that the body of the function starts from here.</p><p>Then we start writing the main body of the function. before writing the next code we have to follow the indentation rule of python (<strong>Indentation refers to the spaces at the beginning of a code line</strong>). So, we write the expression <strong><em>c = a + b</em></strong><em> </em>in the body for storing the addition of two values in variable <em>c</em> and then we print the value which is present in <strong><em>c</em></strong> by using <strong><em>print(c)</em></strong>.</p><p>Now we have told the compiler what is going to happen in the function but we still want to tell the compiler where we want to call that function and we will follow the next process.</p><h3>Calling a Function</h3><p>If you define a function, it will never run automatically, so you have to call the function. And for that, we have to type the code in this syntax <strong><em>function_name (parameter1, parameter2, ….)</em></strong>. Now as we were looking at the program of the addition of two numbers we have defined the function in the above block and now we will see how we will call that function. For that, we have to use the syntax <strong><em>sum(5, 7)</em></strong>.</p><p>The first name of the function and parenthesis next to it is very important for function calls. For this program of “addition of two numbers,” we are using this code <strong><em>sum(5, 7)</em></strong> for calling a function. And what value will go in that parenthesis depends on your function. If your function accepts some parameters then you have to pass the parameters in that parenthesis &amp; if you don’t want any values ​​in the function then it will work even if you don’t pass any parameter in it. It all depends on your function what type of your function is?.</p><p>So, this is all about Functions in Python.</p><p>Below here are some basic programs that will help you to understand more about the function.</p><h4>1. Check whether a number is Prime or not</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17caef92f3e4ed95a486ea2c2130534d/href">https://medium.com/media/17caef92f3e4ed95a486ea2c2130534d/href</a></iframe><h4>2. Convert temperatures to and from celsius, fahrenheit</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/237ed1cd1c3208fbe5a532f4af4f25ab/href">https://medium.com/media/237ed1cd1c3208fbe5a532f4af4f25ab/href</a></iframe><h4>3. Print the Fibonacci sequence</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cc548f3f9f5b6bcc9b8b0eb802c2fe2/href">https://medium.com/media/7cc548f3f9f5b6bcc9b8b0eb802c2fe2/href</a></iframe><h3><strong>Also see these articles</strong></h3><ul><li><a href="https://programtuts.com/python/data-visualization/data-visualization-in-python.php">A Begineer&#39;s Guide to Data Visualization in Python</a></li><li><a href="https://programtuts.com/tensorflow/what-is-tensorflow/what-is-tensorflow.php">What is TensorFlow? A Beginner&#39;s Guide to Know about it.</a></li><li><a href="https://programtuts.com/python/why-python-is-popular/why-python-is-popular.php">Top Reasons Why Python is so Popular in programming Languages ?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b4271701f76" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>