<?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 Shanal Dahanayake on Medium]]></title>
        <description><![CDATA[Stories by Shanal Dahanayake on Medium]]></description>
        <link>https://medium.com/@shanaldahanayake99?source=rss-d71da54b666a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*R6pgHWhF7d3K1_j_</url>
            <title>Stories by Shanal Dahanayake on Medium</title>
            <link>https://medium.com/@shanaldahanayake99?source=rss-d71da54b666a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 19:43:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shanaldahanayake99/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[Fundamentals of Python/02]]></title>
            <link>https://medium.com/@shanaldahanayake99/fundamentals-of-python-02-fe84d52cc7e4?source=rss-d71da54b666a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe84d52cc7e4</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[learn-python]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[basics]]></category>
            <dc:creator><![CDATA[Shanal Dahanayake]]></dc:creator>
            <pubDate>Thu, 10 Oct 2024 03:12:26 GMT</pubDate>
            <atom:updated>2024-10-10T03:12:26.420Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Data Types</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wowS458YkSTqngY9XhAL4Q.jpeg" /></figure><p>In Python, data types can be categorized into primitive types(Integer, Float, String, Boolean) and compound types(Lists, Tuples, Sets, Dictionaries). Here’s a breakdown of each,</p><h3><strong>Primitive Data Types</strong></h3><p><strong>Integer (int)</strong></p><p>Represents whole numbers without a decimal point.</p><pre>a=12<br>b=56</pre><p><strong>Float (float)</strong></p><p>Represents real numbers with a decimal point.</p><pre>a=1.23<br>b=-2.35</pre><p><strong>String (str)</strong></p><p>Represents any character inside a double or single quotation mark.</p><pre>a=&quot;Hello World&quot;</pre><p><strong>Boolean (boolean)</strong></p><p>Represents truth values: True or False</p><pre>a=True<br>b=False</pre><h3><strong>Compound Data Types</strong></h3><p><strong>Lists</strong></p><p>An ordered, mutable collection of items that can be of different data types.</p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*PuJyO90gFNdhDSuWj7tBNw.png" /></figure><p>Find more useful functions from <a href="https://docs.python.org/3/tutorial/datastructures.html">here</a>.</p><p><strong>Tuples</strong></p><p>An ordered, immutable collection of items. Once created, the items cannot be changed. Declare in round brackets.</p><pre>coordinates = (10.0, 20.0)<br>fruits = (&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*WpQUKBGQi-gJgsFcOG6mcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*1jUMok2BfNBQFCym2k_VXg.png" /></figure><p><strong>Sets</strong></p><p>An unordered collection of unique items. Sets are mutable. Cannot contain any duplicate values and does not have indexs.</p><pre>numbers = {1, 2, 3, 4, 5}<br>fruits = {&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*aVpwJuX5ZQIB01M1mm4UqA.png" /></figure><p><strong>Dictionaries</strong></p><p>A collection of key-value pairs where each key is unique. It is mutable.</p><pre>cars = {<br>  &quot;brand&quot;: &quot;Ford&quot;,<br>  &quot;model&quot;: &quot;Mustang&quot;,<br>  &quot;year&quot;: 1964<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*ar9xp0R4oG7YLsuQO6eTLA.png" /></figure><blockquote>Type Casting</blockquote><p><strong>Handling Incompatible Data Types -</strong> Sometimes, operations require specific data types. For example, you can’t directly concatenate an integer with a string without converting one of them to a compatible type. Type casting helps convert the integer to a string to make concatenation possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*ZFRumywwwQmmRNmGYB8Ubw.png" /></figure><p><strong>Using Built-in Functions -</strong> Many built-in Python functions work with specific data types. For instance, if a function expects an integer and you pass a string, type casting ensures the function works correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*6cfKnslXwwBiW6-BELKinw.png" /></figure><p><strong>Performing Mathematical Operations -</strong> Type casting is necessary when performing operations that need certain data types, like integer or float arithmetic. Without it, you could encounter errors or unexpected behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*-QONosIhMhtc1uwC9P8hNA.png" /></figure><p><strong>Special</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*w9FC7iAPB-RtGeaVnbkqNQ.png" /></figure><blockquote>Compound Casting</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*noQFjbXtJ77ec9UdoRWPew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*FTrrLgoksPQwyN3zL-jPLQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe84d52cc7e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fundamentals of Python/01]]></title>
            <link>https://medium.com/@shanaldahanayake99/fundamentals-of-python-01-2e4dc892ee12?source=rss-d71da54b666a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e4dc892ee12</guid>
            <category><![CDATA[fundamentals-of-python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[basic-python]]></category>
            <dc:creator><![CDATA[Shanal Dahanayake]]></dc:creator>
            <pubDate>Thu, 03 Oct 2024 04:08:23 GMT</pubDate>
            <atom:updated>2024-10-03T04:08:23.869Z</atom:updated>
            <content:encoded><![CDATA[<p>Python is a strong and flexible programming language that has established itself as a mainstay in the IT industry. Python is widely taught to beginners due to its ease of use and readability. Despite its simplicity, prominent tech organizations like Google, Facebook, and NASA employ it for advanced applications due to its robustness.</p><p>Python was developed in 1991 by Guido van Rossum with the idea of efficient and readable code. Its simple and easy-to-learn grammar makes it the perfect option for beginners in programming. But Python’s real power is in how versatile the language is, it can be applied to a wide range of tasks, including data analysis, web development, automation, machine learning, artificial intelligence (AI), and even game development.</p><p>Python has become incredibly popular in the last several years, partly because of its vibrant and sizable community, which keeps it growing by constantly producing tools, modules, and frameworks that increase its capabilities. Python is now among the most practical and approachable programming languages due to these innovations.</p><p>Python provides the resources and assistance you need to succeed, whether creating a straightforward script to automate activities or creating intricate machine-learning models. Because of its versatility, effectiveness, and extensive applicability have emerged as the preferred language among numerous developers, data scientists, and engineers.</p><p>Learning Python is an investment in the future because of its increasing popularity in the tech industry. Python offers something for every skill level, whether novices eager to begin coding or experienced developers exploring new languages.</p><blockquote><strong>Mathematical Operations</strong></blockquote><p>Mathematical operations are crucial to programming, and Python makes working with numbers and conducting computations easy and intuitive. Python is an effective tool for everything from straightforward scripts to intricate algorithms in scientific computing because it can perform a broad range of mathematical operations, from simple arithmetic to more complicated computations.</p><p><strong>Addition (+)</strong></p><pre>print(10+20)<br>30</pre><p><strong>Subtraction (-)</strong></p><pre>print(20-10)<br>10</pre><p><strong>Multiplication (*)</strong></p><pre>print(20*10)<br>200</pre><p><strong>Division (/)</strong></p><pre>print(20/10)<br>2</pre><p><strong>Floor Division (//)</strong></p><pre>print(17/5)<br>3</pre><p><strong>Modulus (%)</strong></p><pre>print(17/5)<br>2</pre><p><strong>Power (**)</strong></p><pre>print(2**3)<br>8</pre><blockquote><strong>Order of Operations</strong></blockquote><p>A basic idea in mathematics called BODMAS determines the sequence in which operations are carried out in a mathematical equation. Python evaluates expressions in this sequence, just like the majority of computer languages. Let’s break it down:</p><p>What Is the Meaning of BODMAS?<br><strong>B: Brackets<br>O: Orders (Exponents, including powers and square roots)<br>D: Division<br>M: Multiplication<br>A: Addition<br>S: Subtraction</strong><br>A particular order is followed when performing these procedures to guarantee consistent outcomes. Python evaluates mathematical expressions using the same method.</p><blockquote><strong>Relational Operations</strong></blockquote><p>Relational operations are used to compare two values. In Python, these operations evaluate conditions and return either True or False depending on whether the condition is met. These are often used in control structures like if statements, loops, or while checking conditions in functions.</p><p><strong>Greater than (&gt;)</strong></p><pre>8&gt;9<br>False</pre><p><strong>Less than (&lt;)</strong></p><pre>8&lt;9<br>Frue</pre><p><strong>Greater than or Equal (&gt; =)</strong></p><pre>8&gt;=9<br>False<br><br>8&gt;=8<br>True</pre><p><strong>Less than or Equal (&lt; =)</strong></p><pre>8&lt;=9<br>True</pre><p><strong>Equal (==)</strong></p><pre>8==8<br>True</pre><p><strong>Not Equal (!=)</strong></p><pre>8!=9<br>True<br><br>8!=8<br>False </pre><blockquote><strong>Logical Operators</strong></blockquote><p>Logical operators are used to combine conditional statements or expressions. They allow you to create complex conditions by combining multiple relational or boolean expressions. In Python, logical operators evaluate to either True or False, and they are commonly used in control flow statements like if, while, and for.</p><p><strong>And (and)</strong></p><pre>(9&gt;8) and (10&gt;2) // If one Relational Operation is false the output will be false<br>True</pre><p><strong>Or (or)</strong></p><pre>(9&gt;8) or (10&lt;2) // only one Relational Operation needs to be true for a true output<br>True</pre><p><strong>Not (not)</strong></p><pre>not (4 &lt; 5 or 6 &gt; 10) // The boolean value in the bracket will be inverted<br>False</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e4dc892ee12" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>