<?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 Gowtham Venkatesan on Medium]]></title>
        <description><![CDATA[Stories by Gowtham Venkatesan on Medium]]></description>
        <link>https://medium.com/@basedsentient?source=rss-d6fa01c0deed------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ij-wevdkjC0TqBsTieEXRA.png</url>
            <title>Stories by Gowtham Venkatesan on Medium</title>
            <link>https://medium.com/@basedsentient?source=rss-d6fa01c0deed------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 00:56:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@basedsentient/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[Epic Games Is Pretending to Be the Poor Little David to Apple’s Goliath]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/epic-games-is-pretending-to-be-the-poor-little-david-to-apples-goliath-2aaa2597cdb7?source=rss-d6fa01c0deed------2"><img src="https://cdn-images-1.medium.com/max/1434/1*HenSlWnsuzhXd815e3Fq7Q.png" width="1434"></a></p><p class="medium-feed-snippet">SHOCKER: It&#x2019;s not fighting for the little guy, it&#x2019;s a public negotiation tactic.</p><p class="medium-feed-link"><a href="https://medium.com/swlh/epic-games-is-pretending-to-be-the-poor-little-david-to-apples-goliath-2aaa2597cdb7?source=rss-d6fa01c0deed------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/epic-games-is-pretending-to-be-the-poor-little-david-to-apples-goliath-2aaa2597cdb7?source=rss-d6fa01c0deed------2</link>
            <guid isPermaLink="false">https://medium.com/p/2aaa2597cdb7</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[apple]]></category>
            <dc:creator><![CDATA[Gowtham Venkatesan]]></dc:creator>
            <pubDate>Thu, 20 Aug 2020 16:55:00 GMT</pubDate>
            <atom:updated>2021-09-07T03:34:37.629Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Python Lists in under 10 minutes]]></title>
            <link>https://basedsentient.medium.com/python-lists-in-under-10-minutes-ea4c50e5c54c?source=rss-d6fa01c0deed------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea4c50e5c54c</guid>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Gowtham Venkatesan]]></dc:creator>
            <pubDate>Sat, 28 Dec 2019 14:45:24 GMT</pubDate>
            <atom:updated>2020-08-08T11:46:15.334Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn about the List data type in python</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*luI6oBBtiTwCsRwq9CX96A.png" /></figure><p>In this post let’s discuss the List data type. The list is an ordered collection data type. It’s like an array. Think of it as a variable but instead of a single value you can store multiple values in it. And the values inside these lists can be a combination of numbers, strings, or lists(list inside a list) etc. Lists are indexable and they support slicing as well. Let’s learn all about them!</p><h4>Declaring a variable of the List Type:</h4><p>The syntax for list :<strong> </strong>&lt;variableName&gt; = []. And inside these square brackets, we add the values we want separated by commas. The following example will make things clear.</p><pre>myList = [1, 2, 3, 4, 5] #This is list<br>print(type(myList))</pre><p>We can store any type of value inside a list. For example, we can store a list of strings. Or we can create a list with both numbers and strings. Or we can even have a list inside a list.</p><pre>myList2 = [&quot;Hello&quot;, &quot;This&quot;, &quot;Is&quot;, &quot;A&quot;, &quot;List&quot;]<br>myList3 = [&quot;A&quot;, &quot;List&quot;, &quot;can also contain numbers&quot;, 1, 2, 2.2]<br>print(type(myList2))<br>print(type(myList3))</pre><p>Run the code below and check it out:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flists%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flists%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/30e93d6060f51d3a032f5a78725f6eee/href">https://medium.com/media/30e93d6060f51d3a032f5a78725f6eee/href</a></iframe><h4>You can combine two lists by using the + sign:</h4><p>Paste the code below in the repl window above and run it.</p><pre>myList = [1, 2, 3]<br>myList2 = [4, 5]<br>myList3 = myList + myList2</pre><p>So now myList3 will contain [1, 2, 3, 4, 5] . Same goes for lists consisting of a combination of multiple data types. It just adds the list to the right of the + operator to the list on the left of the + operator.</p><h4>Accessing elements in the list:</h4><p>Because Lists are an ordered sequence of data items we can index them. Just like in Strings. You can access elements inside the list using a method called <strong>Indexing</strong>. Meaning <strong>every data item in the list has a number associated with it</strong>. Using these numbers we can grab parts of the list and we can manipulate them without affecting the original List. All you have to do is pass in the position of the element you want to access to the list. It is important to note that the position of elements in a list or any data type that is indexable starts with 0. Let’s look at an example.</p><pre>myList = [1, 3, &quot;Four&quot;, 5, &quot;Six&quot;, 7]</pre><h4>A List can be indexed in two ways:</h4><ol><li>Positive Indexing</li><li>Negative or reverse indexing</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f-Dsp2GrZmMZqwpYl9StBw.jpeg" /><figcaption>myList indexing</figcaption></figure><h4>1. Positive Indexing:</h4><p>In positive indexing, the list is numbered from <strong>left to right starting with 0</strong>. Yes 0. You start numbering from 0. So <strong>0 will the index value of the first data item </strong>in the list, 1 will be the index value of the second item in the list and so on …</p><h4>2. Negative Indexing:</h4><p>In negative indexing, the list is numbered from the <strong>right to left start with negative 1</strong>. So -1 will the be the index of the first item from the right and you increment as you go on …</p><h4>So to grab a data item from the list:</h4><p>Syntax : listName[index]</p><pre>a = myList[0]  # stores 1 in a <br>b = myList[5]  # stores 7 in b<br>c = myList[-1] # stores 7 in c<br>d = myList[-2] # stores &#39;Six&#39; in d</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flist2%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flist2%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f49c5c4bbd713d07ec607b824d2adff/href">https://medium.com/media/2f49c5c4bbd713d07ec607b824d2adff/href</a></iframe><p>Now, what if we wanted to access multiple items in the list at once?</p><h4>Accessing elements in the list using Slicing:</h4><p>Using slicing we can use <strong>indexing </strong>to grab multiple items of the list. Here’s the Syntax : listName[startIndex : stopIndex].</p><p>The <strong>stop index is excluding</strong> meaning it’ll grab the items only until the stop index but not including the character at the stop index. The <strong>start index is inclusive of the item at the start index</strong>. Run the code below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flist3%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flist3%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/1350c57edb98d7e5fb5ff65f62029d8c/href">https://medium.com/media/1350c57edb98d7e5fb5ff65f62029d8c/href</a></iframe><p>If you don’t understand the code above learn more about slicing in detail check out my previous article on Strings (Link below) where I explain the very same in-depth. Negative Slicing alone doesn’t work as expected with slicing in lists. Negative indexing is possible and will work just fine. Just not negative slicing.</p><p><a href="https://medium.com/pyhack/pystrings-dc0d64b2d1a7">Python Strings in under 10 minutes</a></p><h4>Adding elements to the list:</h4><p>Now if we want to add elements to the list we can use the methods append(), insert() and extend().</p><ol><li><strong>append():</strong></li></ol><p>Using append we can add a single element at the end of the list. <br>In the append() method you simply pass the element to it.</p><blockquote>We’ll learn more about what passing means when we learn about functions in python. For now think of it as sending something to this line of code which in-turn makes use of some other lines of code which python knows by default.</blockquote><p>If it is just numbers you don’t have to bother about the ‘’ . If it is a character or a string you must enclose it in a ‘’ or “”.</p><pre>myList = [1]<br>myList.append(2)</pre><p>2. <strong>insert():</strong></p><p>Using the insert() method we can add elements at a specific index in the list.<br>In the insert() method we pass in the index (position) we want to add the element followed by the actual element. This will add the element at the specified index pushing the other elements in the list towards the right.</p><pre>myList1 = [1, 3, 4, 5]<br>myList1.insert(1, 2)</pre><p>3. <strong>extend():</strong></p><p>In the extend() method we need to pass the elements to it as another list (in [] separated by commas).</p><pre>myList2 = [&quot;Hello&quot;]<br>myList2.extend([&quot;World&quot;, &quot;!&quot;])</pre><p>If you just pass in using ‘’ or “” it’ll add each character of the element as a new item on the list you are performing the method on.</p><pre>myList3 = [&#39;H&#39;, &#39;E&#39;, &#39;L&#39;]<br>myList3.extend(&#39;LO&#39;)</pre><p>Run the code below to see the output of the above code.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flists2%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flists2%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/9652682c5c4f894ec75b1cc040ff5b48/href">https://medium.com/media/9652682c5c4f894ec75b1cc040ff5b48/href</a></iframe><h4>Deleting elements from the list:</h4><p>Now if we want to delete elements from the list we can use the pop(), del() or the remove() methods.</p><ol><li><strong>pop():</strong></li></ol><p>The pop() method will remove a single element from the end of the list each time it is used. You can optionally pass the index to the pop() method to delete elements at a particular index.</p><pre>myList = [1, 2, 2, 3, 4, 5, 5]<br>myList.pop()</pre><p>2. <strong>del():</strong></p><p>Using the del() method we can delete an element at a specific index. You need to pass the index of the element you want to delete to it. The del() syntax is a little different. We use del Listname[index]. The only difference between del() and pop() is that pop() returns the element that is being deleted while the del() does not.</p><pre>del myList[5]</pre><p>3. <strong>remove():</strong></p><p>And using the remove() we can remove the first occurrence of the element in the list. Meaning if the list1 has [1,2,3,2,4] using remove(2) on it deletes the 2 at index 1 and not the one index 3 as well. It stops after deleting the first occurrence the element you pass to it.</p><pre>myList.remove(2)</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flists3%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flists3%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/f421ae0d118f8ab67462fc27933aefa5/href">https://medium.com/media/f421ae0d118f8ab67462fc27933aefa5/href</a></iframe><h4>Bonus operations on List:</h4><p>There are a few additional useful methods that you can apply to Lists such as sort(), reverse(), extend() and index().</p><ol><li><strong>sort():</strong></li></ol><p>If your list consists of numbers you can use the sort method to store the numbers in the list in ascending or descending order. Same goes for strings in the list(based on the first character of the string). This ascending/descending order is dependent on the actual values of the elements in the list. For descending order alone we need to pass something a little special to the method. We need to pass reverse <strong>=</strong> True to the sort() method for descending.</p><pre>myList = [1, 4, 8, 9, 3]<br>myList.sort() <br>myList.sort(reverse = True)<br>myList1 = [&#39;a&#39;, &#39;z&#39;, &#39;y&#39;, &#39;e&#39;, &#39;b&#39;]<br>myList1.sort()<br>myList1.sort(reverse = True)</pre><p>2. <strong>reverse():</strong></p><p>As the name suggests, it is used to reverse the elements in the list but based on the index and not on the actual values.</p><pre>myList2 = [1, 3, 2, 5, 6]<br>myList2.reverse()</pre><p>3. <strong>extend():</strong></p><p>Using the extend() method we can combine two lists just like we did with + operator we discussed earlier.</p><pre>myList = [1, 2, 3]<br>myList2 = [4, 5]<br>myList.extend(myList2)</pre><p>This method updates the list we were applying it to show the concatenation of the two original lists.</p><p>4. <strong>index():</strong></p><p>This method searches for the element we pass to it from the start of the list and returns its index. If the given element isn’t present it throws an error.</p><pre>myList = [1, 2, 3]<br>index = myList.index(3)<br>print(index)<br># index2 = myList.index(4)<br># The above line will throw an error</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flists4%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Flists4%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/1bee88ac23b43e382493c7685ad4c5c2/href">https://medium.com/media/1bee88ac23b43e382493c7685ad4c5c2/href</a></iframe><p>In this post we learned about the List Data Type, how to declare it, add lists together, indexing, slicing and it’s madness. We learnt some useful methods that we can apply on Lists as well. We can also have lists inside a list, even dictionaries, sets and tuples. We’ll learn more about them in a later post.</p><h3>And that’s pretty much it for the List Data Type in Python. What? I’m serious. This is all you need to know about Lists. For Now.</h3><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>If you enjoyed this content, make sure you follow the publication for future posts.</h3><h3>Peace Out ✌️</h3><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h4>In the next episode: It’s all about sets</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea4c50e5c54c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Strings in under 10 minutes]]></title>
            <link>https://basedsentient.medium.com/pystrings-dc0d64b2d1a7?source=rss-d6fa01c0deed------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc0d64b2d1a7</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Gowtham Venkatesan]]></dc:creator>
            <pubDate>Tue, 24 Dec 2019 19:04:06 GMT</pubDate>
            <atom:updated>2020-08-08T11:18:56.265Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn the basics of the Python Data type Strings</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XO4EBUhUFi_hPc7wgKy0eQ.png" /></figure><p>Every value that we work with in Python has a type. A <strong>data type</strong> is a classification that specifies which type of value a variable has and what type of operations can be applied to it. This post is a quick introduction to the <strong>String </strong>data type in python. Let’s get started!</p><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>Strings</h3><p>An ordered sequence of characters is called a <strong>String</strong>. Anything under a ‘ ‘ single-quote or a “ “ is a string. It is used to store sentences, words, characters, special symbols, spaces etc. A username is an example of where strings might be used in real life.</p><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>Declaring the String Data Type:</h3><p>All you have to do is assign a variable name to the string of your choice in ‘’ or a “”. And that’s pretty much it.</p><pre>myStr = &#39;a&#39;<br>myStr2 = &quot;The quick brown fox jumps over the lazy dog&quot;<br>myStr3 = &quot;!@#$%^&amp;*()_+&quot;<br>myStr4 = &#39;222&#39;</pre><p>Run the code below and see for yourself :</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstrings%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstrings%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/af49eb21e20960af4af089ded7f8048d/href">https://medium.com/media/af49eb21e20960af4af089ded7f8048d/href</a></iframe><p>Any sequence of characters. ANY. Anything under a ‘ ‘ or a “ “ is a string.<br>Even if it’s a number and it’s inside a ‘ ‘ it’s considered as a string. I repeat ANY. ANYTHING INSIDE IT.</p><h4>You can also add strings using the + operator:</h4><p>The code below is pretty self-explanatory. Run the code and see the results.</p><pre>myStr = &quot;Hello&quot;<br>myStr2 = &quot;World&quot;<br>myStr3 = myStr + myStr2 + &quot;!&quot;<br>print(myStr + myStr2 + &quot;!&quot;)<br>print(&quot;Hello&quot; + myStr2 + &quot;!&quot;)<br>print(myStr + &quot;World&quot; + &quot;!&quot;)<br>print(&quot;Hello&quot; + &quot;World&quot; + &quot;!&quot;)</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstring%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstring%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/614382241863f768cca42ff2f317183d/href">https://medium.com/media/614382241863f768cca42ff2f317183d/href</a></iframe><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>Indexing :</h3><p>Because strings are an ordered sequence of characters we can index them. Meaning <strong>every character in the string has a number associated with it</strong>. Using these numbers we can grab parts of the string and we can manipulate them without affecting the original string. Let me show you what I’m talking about.</p><p>Let’s Look at an example of the string “Lasagna”. Let’s declare it.</p><pre>myString = &quot;Lasagna&quot; #This is a string<br>myString = &#39;Lasagna&#39; # You can also use &#39; &#39; instead of &quot; &quot;</pre><h4><strong>A String can be indexed in two ways:</strong></h4><ol><li>Positive Indexing</li><li>Negative or reverse indexing</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9voko6oLixeUbvKWq1OIAA.jpeg" /></figure><h4><strong>1. Positive Indexing:</strong></h4><p>In positive indexing, the string is numbered from <strong>left to right starting with 0</strong>. Yes 0. You start numbering from 0. So <strong>0 will the index value of the first character </strong>in the string, 1 will be the index value of the second character and so on …</p><h4><strong>2. Negative Indexing:</strong></h4><p>In negative indexing, the string is numbered from the <strong>right to left start with negative 1</strong>. *For Obvious reasons. You do know right?*. So -1 will the be the index of the first character from the right and you increment as you go on …</p><h4>So to grab a character from a string:</h4><p>Syntax : variableName[index]</p><pre>myString = &quot;Lasagna&quot;<br>a = myString[0]  # stores &#39;L&#39; in a <br>b = myString[6]  # stores &#39;a&#39; in b<br>c = myString[-1] # stores &#39;a&#39; in c<br>d = myString[-5] # stores &#39;s&#39; in d</pre><p>Edit the code below and try to grab ‘g’ and store it in a new variable e.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstrings1%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstrings1%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbe857e2e20904c4501b60313bf9c0c4/href">https://medium.com/media/fbe857e2e20904c4501b60313bf9c0c4/href</a></iframe><p><strong>Any character in a string is indexable.</strong> Even <strong>spaces</strong> in between sentences. So even the spaces should be numbered and considered during indexing.</p><p>Okay so now what if we want to grab multiple characters? This is where <strong>slicing</strong> comes in.</p><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>Slicing:</h3><p>In slicing, we’ll use <strong>indexing </strong>to grab a portion of the original string. Here’s the Syntax : variableName[startIndex : stopIndex].</p><pre>myString = &quot;The Council of Water Sheep&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fr6JUGl0DiwjyHmJ9XBanw.png" /></figure><p>Say for example you want to grab the first 10 characters in the myString variable. All you have to do is mention the start index followed by a : then the stop index. The <strong>stop index is excluding</strong> meaning it’ll grab the characters only until the stop index but not including the character at the stop index. The <strong>start index is inclusive</strong>.</p><p>So we can modify the syntax as follows: variableName[startIndex : stopIndex + 1]. The + 1 is to include the character at the stop index. Just increment it to the next number. In the case of negative indexing if the index is -16 for example, incrementing it by one should give you -15 and so on...<br>This slicing operation isn’t visible in the output section unless you print it or store it in a variable and then print it.</p><h4><strong>So let’s try and grab the first 10 characters: </strong>“The Council” :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0KZex8P-srQHsixjOCuvQ.jpeg" /><figcaption>First 10 characters of myString</figcaption></figure><h4>Positive Indexing :</h4><pre>a = myString[0:11]<br>print(a) </pre><p>0 is the start of the index and 10 is the stop index for the substring we are trying to grab. But since the stop index isn’t inclusive we increment it to 11.</p><h4>Negative Indexing :</h4><pre>myString[-26:-15]</pre><p>-26 is the start index and -16 is the stop index. But we increment it to -15. *Why?*</p><p>We normally use negative indexing to access the characters towards the end of the string as it is easier to number. But you can use negative indexing to grab the characters at the beginning of the string as well.</p><p>Refer to the index mapping of the string in the image above to get a better understanding.</p><h4>Now let’s grab ‘water’ from the string :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jjL6Pljn81xSamE4jnpgLQ.jpeg" /><figcaption>WATER substring from myString</figcaption></figure><h4>Positive Indexing :</h4><pre>myString[15:20]</pre><h4>Negative Indexing :</h4><pre>myString[-11:-6]</pre><p>Run the code below to check it out!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstrings3%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstrings3%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf71eae30ce6c375609c8da3d5957502/href">https://medium.com/media/bf71eae30ce6c375609c8da3d5957502/href</a></iframe><h4><strong>Let’s grab the last 8 characters now :</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LtwBiS8pDMeTafVj2QjfVw.jpeg" /><figcaption>The last 8 characters of myString</figcaption></figure><h4>Positive Indexing</h4><pre>myString[18:26]</pre><p>Should work just fine. As expected.</p><h4>Negative Indexing</h4><pre>myString[-8:-1] # Something&#39;s wrong I can feel it</pre><p>Something’s wrong in the above line of code. The last character has the value of -1. You can’t increment it to 0 and expect it to return the desired outcome. It messes up the order. So you leave the stop index blank. Don’t freak out. Just keep reading.</p><h4><strong>Leaving the start or stop index blank:</strong></h4><h4>Case 1: Stop index is blank:</h4><p>If we leave the stop index blank then the slicing will grab <strong>all the characters from the start index till the end of the string</strong>. Let’s try and grab the ‘Sheep’ substring from myString.</p><pre>myString[21:] # Positive indexing<br>myString[-8:] # Negative indexing</pre><p>21 / -8 is the start of the index for the substring ‘Sheep’. We specify the start string alone and leave the stop index blank so it’ll grab everything from 21 / -8 till the very end of the string.</p><h4>Case 2: Start index is blank:</h4><p>If we leave the start index blank then the slicing will grab<strong> all the characters from the start of the string till the stop index</strong>. Let’s grab the first 10 characters of myString by leaving the start index blank.</p><pre>myString[:10] # Positive indexing<br>myString[:-16] # Negative indexing</pre><p>10 / -16 is the stop index to grab the first 10 characters from the string. We leave the start index blank. So this slicing operation grabs everything from the start of the string until the stop index.</p><h4>Case 3: Both the Start and Stop index are blank:</h4><p>If both the start and stop index is blank then the slicing operation will grab the entire string. Because there is no start or stop conditions mentions.</p><pre>myString[:]</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstrings4%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstrings4%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/e066895d585c7b380f3f06bda9628d82/href">https://medium.com/media/e066895d585c7b380f3f06bda9628d82/href</a></iframe><h4>There’s this thing called the step index:</h4><p>Optionally you can include this thing called the <strong>step value </strong>using which you can skip characters which are grabbed during the slicing operation. This step index is right after the stop index.<br>Syntax : variableName[startIndex : stopIndex: stepValue]</p><p>So if we set the stop value as 2 it’s going to skip 2 characters for every 2 characters grabbed.</p><pre>myString = &quot;Encyclopaedia&quot;<br>myString[0:8:2]</pre><p>So the above code is going to grab the characters from the start index until the stop index 8 but only every 2 alternate characters.</p><p>So normally if the slicing was myString[0:8] it would grab the substring : Encyclop. But if we add the step value myString[0:8:2] it would return Ecco.</p><p>You can leave the start/stop/step values blank in any varying combinations. Let me show you what I’m talking about.</p><pre>myString[0::3]<br>myString[:6:2]<br>myString[::2]</pre><p>Run the code to see the results :</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstrings5%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fstrings5%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d72321918e49bfd5fa06c6252a8c467/href">https://medium.com/media/6d72321918e49bfd5fa06c6252a8c467/href</a></iframe><p>Well, I hope you understood slicing properly. We’ll be using this concept in other data types as well. So get comfortable with it. It isn’t going anywhere.</p><p>If you’ve reached till here, GOOD JOB! Baby steps! One at a time! In this post, we learned about the Strings Data Type, how to declare it, add strings together, indexing, and slicing. We have some useful methods that we can apply on strings. We’ll look at them in another post. We need to learn a few more concepts first.</p><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>And that’s pretty much it for the Strings Data Type in Python. What? I’m serious. This is all you need to know about String. For Now.</h3><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>If you enjoyed this content, make sure you follow the publication for future posts.</h3><h3>Peace Out ✌️</h3><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h4>In the next episode: <a href="https://medium.com/pyhack/python-lists-in-under-10-minutes-ea4c50e5c54c">It’s all about Lists</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc0d64b2d1a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Numbers in under 10 minutes]]></title>
            <link>https://basedsentient.medium.com/pythonnumbers-3d619995fe36?source=rss-d6fa01c0deed------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d619995fe36</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Gowtham Venkatesan]]></dc:creator>
            <pubDate>Sun, 22 Dec 2019 20:44:21 GMT</pubDate>
            <atom:updated>2020-08-08T11:01:18.105Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn the basics of the Python Data type Numbers</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JgJpUJ-tWcmrFKxzbb4YAQ.png" /></figure><p>Every value that we work with in Python has a type. A <strong>data type</strong> is a classification that specifies which type of value a variable has and what type of operations can be applied to it. It’s as simple as that. This article is a quick introduction to the <strong>Numbers </strong>data type in python. So let’s get started!</p><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>Numbers</h3><p>Numbers are the most basic data types in Python. Any number that you assign to a variable is of the data type ‘<strong>Number</strong>’.</p><p>Now within Numbers, there are three classes :</p><ol><li><strong>Integer</strong></li><li><strong>Floating point numbers</strong></li><li><strong>Complex Numbers</strong></li></ol><p>These are the types of Numbers Python supports.</p><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>1. Integer (int) :</h3><p>Any and every whole number falls in ‘int’ class. Any number without decimals is an Integer.</p><pre>myVar1 = 20<br>myVar2 = 10000<br>myVar3 = 0</pre><p>Let’s quickly check the type of the above variables using the type() method.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Finteger%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Finteger%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac550074ac14aacad1a6c7668d0c25d8/href">https://medium.com/media/ac550074ac14aacad1a6c7668d0c25d8/href</a></iframe><p>Run the code by hitting the big green play button. You can also edit the code and run it as well.</p><p>If you run the code above by clicking on the big green play button, you’ll get an output saying these variables are of &lt;class ‘int’&gt;. This tells us the type(class) the variable belongs to.</p><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>2. Floating Point Numbers (float) :</h3><p>All decimal numbers fall under the ‘float’ class. Any number with decimals is of a float type. The result of a division operation between two numbers results in a floating-point number. Even if the result is a whole number it will be converted to floating-point.</p><pre>myVar = 1.2345<br>myVar2 = 1231.232323<br>myVar3 = 6/3  <br># Even though the result is 3 which is a whole number, it will be be converted to a floating point number resulting in the value 3.00</pre><p>Let’s quickly run the above code:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Ffloat%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Ffloat%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/816ff32fd39dfe11f455ee01c35d325b/href">https://medium.com/media/816ff32fd39dfe11f455ee01c35d325b/href</a></iframe><p>If you run the code above, you’ll get an output saying these variables are of the &lt;class ‘float’&gt;.</p><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>3. Complex Numbers (complex) :</h3><p>Complex numbers are specified as &lt;real part&gt; + &lt;imaginary part&gt;j. Just like how you would do in regular math. But this type is rarely used.</p><pre>myVar = 2 + 3j<br>myVar2 = 6 + 3j<br>print(type(myVar))<br>print(type(myVar2))<br>print(myVar + myVar2)</pre><p>Run the code below!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fnumbers3%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fnumbers3%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e279c024cbac6f7d97184bfc69626c0/href">https://medium.com/media/2e279c024cbac6f7d97184bfc69626c0/href</a></iframe><p>If you check the type of the above variable, it’ll return &lt;class ‘complex’&gt;.</p><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>Operations on Numbers:</h3><p>We can perform the basic mathematical operations on numbers using what is known as an “operator”. It’s nothing but a symbol that defines what type of operation you want to perform on numbers. You can use these operators to perform operations on variables containing numbers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8r78oufqmo5_C1uv_BQq9g.jpeg" /><figcaption>Gotta love gradients</figcaption></figure><h4>Addition :</h4><p><strong>The </strong>+<strong> operator is used for addition.</strong></p><pre>myVar1 = 1 + 2<br>myVar2 = 3 + 5<br>myVar3 = myVar1 + myVar 2</pre><h4>Subtraction :</h4><p><strong>The </strong>-<strong> operator is used for subtraction.</strong></p><pre>myVar1 = 1 - 2<br>myVar2 = 3 - 5<br>myVar3 = myVar1 - myVar 2</pre><h4>Multiplication :</h4><p><strong>The </strong>*<strong>operator is used for multiplication.</strong></p><pre>myVar1 = 1 * 2<br>myVar2 = 3 * 5<br>myVar3 = myVar1 * myVar 2</pre><h4>Division :</h4><p><strong>The </strong>/<strong> operator is used for division.</strong></p><pre>myVar1 = 4 / 2<br>myVar2 = 2 / 1<br>myVar3 = myVar1 * myVar 2</pre><h4>Modulus :</h4><p><strong>The </strong>%<strong> operator is used to find the remainder of a division operation.</strong></p><pre>myVar = 6 % 4<br># Which will give you 2.</pre><h4>Exponent or Power or whatever:</h4><p>The ** operator is used to raise the number on the left side of the operator to the power of the number on the right side of the operator.</p><pre>myVar = 2 ** 3<br>myVar2 = 2 ** 2<br>myVar3 = 3 ** 3</pre><p>Okay so now let’s run the code on a repl portal and see the results.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fnumbers4%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2F%40Gothamv%2Fnumbers4%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/d72f133c19abe3127fc19c2f0fda6fb2/href">https://medium.com/media/d72f133c19abe3127fc19c2f0fda6fb2/href</a></iframe><p>You can also use () to separate multiple mathematical operations just like you would on a calculator.</p><pre>myVar = (1 + 2) * (3 / 4)<br>myVar = (3 * 4) / (6 / 3)<br>myVar = ((3 * 4) / (6 / 3) - (1 + 2) * (3 / 4))<br># And so on ...<br># You get the point. Right?</pre><p>If you’ve reached till here, GOOD JOB! You’ve taken your first steps into learning Python. In this post we learned about the Numbers Data Type, it’s subtypes and the operations you can perform on it. In the next post, we’ll learn more about strings.</p><h3>And that’s pretty much it for the Numbers Data Type in Python. What? I’m serious. This is all you need to know about numbers.</h3><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h3>If you enjoyed the article, make sure you follow the publication for future posts. Follow me as well. Because why not? Do it! Do it NOW!</h3><h3>Peace Out ✌️</h3><p>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</p><h4>In the next episode: <a href="https://medium.com/pyhack/pystrings-dc0d64b2d1a7">It’s all about Strings</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d619995fe36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get Started with Python in under 10 minutes]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://basedsentient.medium.com/get-started-with-python-in-under-10-minutes-20711b5381c6?source=rss-d6fa01c0deed------2"><img src="https://cdn-images-1.medium.com/max/2600/1*Uk20QAl1IpRKK4Ut7b3vYg.png" width="3840"></a></p><p class="medium-feed-snippet">A Beginners Guide to Programming in Python</p><p class="medium-feed-link"><a href="https://basedsentient.medium.com/get-started-with-python-in-under-10-minutes-20711b5381c6?source=rss-d6fa01c0deed------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://basedsentient.medium.com/get-started-with-python-in-under-10-minutes-20711b5381c6?source=rss-d6fa01c0deed------2</link>
            <guid isPermaLink="false">https://medium.com/p/20711b5381c6</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Gowtham Venkatesan]]></dc:creator>
            <pubDate>Sat, 10 Aug 2019 13:03:51 GMT</pubDate>
            <atom:updated>2019-08-25T06:54:32.576Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Learn the Basics of Git in Under 10 Minutes]]></title>
            <link>https://medium.com/free-code-camp/learn-the-basics-of-git-in-under-10-minutes-da548267cc91?source=rss-d6fa01c0deed------2</link>
            <guid isPermaLink="false">https://medium.com/p/da548267cc91</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Gowtham Venkatesan]]></dc:creator>
            <pubDate>Sat, 05 Jan 2019 17:15:44 GMT</pubDate>
            <atom:updated>2020-12-09T06:10:54.741Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4kDk9CZEEJBllqd3Fx549A.png" /></figure><p>Yes, the title is clickbait. There is no way you can <em>understand</em> the basics of git technology in just 10 minutes. But you can get pretty close in about 25 minutes. And that is the purpose of this article.</p><p>If you want to get started on learning about Git technology, you’ve come to the right place. This is a comprehensive beginner’s guide to Git. There are many clients for Git. The technology is all the same no matter the client. But in this guide, we’ll be using GitHub to understand Git.</p><p>You can read a Portuguese supplement to the article <a href="https://github.com/Gothamv/MuskCult/blob/master/README.brazilian_portuguese.md">here</a>. Translations are welcome! Just send me a pull request.</p><h4>Let’s get started!</h4><h3>What is Version Control?</h3><blockquote>Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. So ideally, we can place any file in the computer on version control.</blockquote><h4>Umm… Okay… But Why Tho?</h4><h4>Here’s Why:</h4><p>A Version Control System (VCS) allows you to revert files back to a previous state, revert the entire project back to a previous state, review changes made over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Using a VCS also means that if you screw things up or lose files, you can generally recover easily. And sometimes you just want to know <strong>“who wrote this crap”</strong>, and having access to that information is worthwhile 😈.</p><h3>So What is Git?</h3><p>Git is a version-control system for tracking changes in computer files and coordinating work on those files among multiple people. Git is a <strong><em>Distributed Version Control System</em></strong>. So Git does not necessarily rely on a central server to store all the versions of a project’s files. Instead, every user “clones” a copy of a repository (a collection of files) and has the <strong><em>full</em></strong> history of the project on their own hard drive. This clone has <em>all</em> of the metadata of the original while the original itself is stored on a self-hosted server or a third-party hosting service like GitHub.</p><p>Git helps you <strong><em>keep track of the changes</em></strong> you make to your code. It is basically the history tab for your code editor(With no incognito mode 🌚). If at any point while coding you hit a fatal error and don’t know what’s causing it you can always revert back to the stable state. So it is very helpful for debugging. Or you can simply see what changes you made to your code over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lp_67l9zwur7aaFAhpVDrg.png" /><figcaption>A simple example of version history of a file.</figcaption></figure><p>In the example above, all three cards represent different versions of the same file. We can select which version of the file we want to use at any point in time. So I can jump to and fro to any version of the file in the git time continuum.</p><p>Git also helps you <strong><em>synchronise code</em></strong> between multiple people. So imagine you and your friend are collaborating on a project. You both are working on the same project files. Now Git takes those changes you and your friend made independently and merges them into a single “<strong>Master</strong>” repository. So by using Git you can ensure you both are working on the most recent version of the repository. So you don’t have to worry about mailing your files to each other and working with a ridiculous number of copies of the original file. And collaborating long-distance becomes as easy as HTML 🙃.</p><h3>Git Workflow:</h3><p>Before we start working with Git commands, it is necessary that you understand what it represents.</p><h4>What is a Repository?</h4><p>A <strong>repository</strong> a.k.a. <strong>repo</strong> is nothing but a collection of source code.</p><h4>There are four fundamental elements in the Git Workflow.</h4><p><strong>Working Directory</strong>, <strong>Staging Area</strong>, <strong>Local Repository,</strong> and <strong>Remote Repository</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*iL2J8k4ygQlg3xriKGimbQ.png" /><figcaption>Diagram of a simple Git Workflow</figcaption></figure><p><strong>If you consider a file in your Working Directory, it can be in three possible states.</strong></p><ol><li><strong>It can be staged.</strong> This means the files with the updated changes are marked to be committed to the local repository but not yet committed.</li><li><strong>It can be modified</strong>. This means the files with the updated changes are not yet stored in the local repository.</li><li><strong>It can be committed</strong>. This means that the changes you made to your file are safely stored in the local repository.</li></ol><ul><li>git add is a command used to add a file that is in the working directory to the staging area.</li><li>git commit is a command used to add all files that are staged to the local repository.</li><li>git push is a command used to add all committed files in the local repository to the remote repository. So in the remote repository, all files and changes will be visible to anyone with access to the remote repository.</li><li>git fetch is a command used to get files from the remote repository to the local repository but not into the working directory.</li><li>git merge is a command used to get the files from the local repository into the working directory.</li><li>git pull is a command used to get files from the remote repository directly into the working directory. It is equivalent to a git fetch and a git merge .</li></ul><p><strong>Now that we know what Git is and its basic terminologies, let’s see how we can place a file under git</strong>. We’re going to do it the right way and the difficult way. Without any GUI applications.</p><p>I’m assuming you already have a file you want to place under version control. If not create a sample folder named ‘MuskCult’ and place some sample code files in it.</p><h3>Step 0: Make a GitHub Account. Duh.</h3><p>If you don&#39;t already have one, you can make one <a href="https://github.com/join">here</a>.</p><h3>Step 1: Make sure you have Git installed on your machine.</h3><p>If you are on a <strong>Mac</strong>, fire up the terminal and enter the following command:</p><pre>$ <strong>git --version</strong></pre><p>This will prompt open an installer if you don’t already have git. So set it up using the installer. If you have git already, it’ll just show you which version of git you have installed.</p><p>If you are running <strong>Linux</strong>(deb), enter the following in the terminal:</p><pre>$ <strong>sudo apt install git-all</strong></pre><p>If you are on <strong>Windows</strong>:</p><pre>$ <strong>get a mac</strong></pre><p>Just kidding… Relax… The number of people I triggered… Phew…<br>Go to this <a href="https://www.apple.com/macos/what-is/"><strong>link</strong></a> or this<strong> </strong><a href="https://gitforwindows.org/"><strong>link</strong></a> for more info on how to get it.</p><h3>Step 2: Tell Git who you are.</h3><p>Introduce yourself. Slide in. Seriously, mention your Git username and email address, since every Git commit will use this information to identify you as the author.</p><pre>$ <strong>git config --global user.name &quot;YOUR_USERNAME&quot; </strong></pre><pre>$ <strong>git config --global user.email &quot;im_satoshi@musk.com&quot;</strong></pre><pre>$ <strong>git config --global --list</strong> # To check the info you just provided</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*JbyUdhLMEdglRxQk6PH7Vg.gif" /></figure><h3>Step 3: Generate/check your machine for existing SSH keys. (Optional)</h3><p>Why you ask? Using the <strong>SSH protocol</strong>, you can<strong> connect and authenticate</strong> to r<strong>emote servers and services</strong>. With SSH keys, you can connect to GitHub without supplying your username or password at each visit.</p><p>Follow this<strong> </strong><a href="https://help.github.com/articles/about-ssh/"><strong>link</strong></a><strong> </strong>to learn more about SSH.<br>Go <a href="https://help.github.com/articles/checking-for-existing-ssh-keys/"><strong>here</strong></a><strong> </strong>to check if you have an existing SSH key.<br>Go <a href="https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/"><strong>here</strong></a> to generate a SSH Key.<br>Go <a href="https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/"><strong>here</strong></a><strong> </strong>to add the SSH key to your GitHub account.<br>And finally, go <a href="https://help.github.com/articles/testing-your-ssh-connection/"><strong>here</strong></a> to test its connection.</p><p>If you did setup SSH, every git command that has a link you replace it by:</p><pre><strong>Instead of : https://github.com/username/reponame</strong></pre><pre><strong>You use    : git@github.com/username/reponame.git</strong></pre><pre>      <strong>     Note : You can use both ways alternatively</strong></pre><p><strong>I’ll be using SSH protocol in this tutorial.</strong></p><h3>Step 4: Let’s Git</h3><p>Create a new repository on GitHub. Follow this <a href="https://github.com/new">link</a>.<br>Now, locate the folder you want to place under git in your terminal.</p><pre>$<strong> cd Desktop/MuskCult</strong></pre><h4>Initialize Git:</h4><p>And to place it under git, enter:</p><pre>$<strong> touch README.md</strong>    # To create a README file for the repository<br>$ <strong>git init </strong>          # Initiates an empty git repository</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Q_DUXRghgFQb9F47mUB6LQ.gif" /></figure><p>Now go edit the README.md file to provide information about the repository.</p><h4>Add files to the Staging Area for commit:</h4><p>Now to add the files to the git repository for commit:</p><pre>$ <strong>git add .</strong>  <br># Adds all the files in the local repository and stages them for commit</pre><pre><strong>OR</strong> if you want to add a specific file</pre><pre>$ <strong>git add README.md</strong> <br># To add a specific file</pre><h4>Before we commit let’s see what files are staged:</h4><pre>$ <strong>git status </strong># Lists all new or modified files to be committed</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*a2_hw7cMe2R9R_aI86dB-A.gif" /></figure><h4>Commit Changes you made to your Git Repo:</h4><p>Now to commit files you added to your git repo:</p><pre>$ <strong>git commit -m &quot;First commit&quot;<br></strong># The message in the &quot; &quot; is given so that the other users can read the message and see what changes you made</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*LoUwFy29RkgCS7hCajd_3g.gif" /></figure><h4>Uncommit Changes you just made to your Git Repo:</h4><p>Now suppose you just made some error in your code or placed an unwanted file inside the repository, you can unstage the files you just added using:</p><pre>$<strong> </strong><strong>git reset HEAD~1<br></strong># Remove the most recent commit<br># Commit again!</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*rxOX_U-ZRmGfhgIhNWlDIQ.gif" /></figure><h4>Add a remote origin and Push:</h4><p>Now each time you make changes in your files and save it, it won’t be automatically updated on GitHub. All the changes we made in the file are updated in the local repository. Now to update the changes to the master:</p><pre>$ <strong>git remote add origin <em>remote_repository_URL<br></em></strong><em># </em>sets the new remote</pre><p>The <strong>git remote</strong> command lets you create, view, and delete connections to other repositories.</p><pre><em>$ </em><strong>git remote -v<br></strong># List the remote connections you have to other repositories.</pre><p>The <strong>git remote -v</strong> command lists the URLs of the remote connections you have to other repositories.</p><pre>$ <strong>git push -u origin master </strong># pushes changes to origin</pre><p>Now the <strong>git push </strong>command pushes the changes in your local repository up to the remote repository you specified as the origin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*w-nfopsKIks_JRzFe5D8xA.gif" /></figure><p>And now if we go and check our repository page on GitHub it should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQljQFkytY84BgmlVtpgmw.png" /></figure><p>And that’s it. You’ve just added the files to the repository you just created on GitHub.</p><h4>See the Changes you made to your file:</h4><p>Once you start making changes on your files and you save them, the file won’t match the last version that was committed to git. To see the changes you just made:</p><pre>$ <strong>git diff </strong># To show the files changes not yet staged</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*xym1QvvvWorfoyGMXv28Yg.gif" /></figure><h4>Revert back to the last committed version to the Git Repo:</h4><p>Now you can choose to revert back to the last committed version by entering:</p><pre>$ <strong>git checkout .</strong></pre><pre><strong>OR</strong> for a specific file</pre><pre>$ <strong>git checkout -- &lt;filename&gt;</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*HYgYkfo3W4MUA8CJl12rXg.gif" /></figure><h4>View Commit History:</h4><p>You can use the <strong>git log</strong> command to see the history of commits you made to your files:</p><pre>$ <strong>git log</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*9w7uBJcQMxc708DBw8Sewg.gif" /></figure><p>Each time you make changes that you want to be reflected on GitHub, the following are the most common flow of commands:</p><pre>$ <strong>git add .</strong><br>$<strong> git status </strong># Lists all new or modified files to be committed<strong><br></strong>$ <strong>git commit -m &quot;Second commit&quot;<em><br></em></strong>$ <strong>git push -u origin master</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*rWBJnBdF1V8YO_mi-jEfxA.gif" /></figure><p>Now if we go and see our repo, we can identify whether the commit was successful by looking at the commit message for each file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QHM8m5HGavHkdzPz06UWGw.png" /></figure><h3>Step 5: That’s all well and good… But How do I download and work on other repositories on GitHub?</h3><h4>Cloning a Git Repo:</h4><p>Locate to the directory you want to clone the repo. Copy the link of the repository you want and enter the following:</p><pre>$<strong> git clone <em>remote_repository_URL</em></strong></pre><p>Feel free to go ahead and clone the repo I created above using: <a href="https://github.com/Gothamv/MuskCult">https://github.com/Gothamv/MuskCult</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*6NACk8-IiBjbauM-k-aesQ.gif" /></figure><h4>Pushing Changes to the Git Repo:</h4><p>Now you can work on the files you want and commit to changes locally. If you want to push changes to that repository you either have to be <a href="https://help.github.com/articles/inviting-collaborators-to-a-personal-repository/">added as a collaborator</a> for the repository or you have created something known as a pull request. Go and check out how to do one <a href="https://help.github.com/articles/creating-a-pull-request/">here</a> and give me a pull request with your code file.</p><h4>Collaborating:</h4><p>So imagine you and your friend are collaborating on a project. You both are working on the same project files. Each time you make some changes and push it into the master repo, your friend has to pull the changes that you pushed into the git repo. Meaning to make sure you’re working on the latest version of the git repo each time you start working, a git pull command is the way to go.</p><p>Now below is an example of a project my friend and I are collaborating on:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2-tl2rHsgPqiv88aI55CPw.png" /><figcaption>There has just been a commit on the repo</figcaption></figure><p>So to make sure those changes are reflected on my local copy of the repo:</p><pre>$ <strong>git pull origin master</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*ySDKu2OEdkc26yOUp-TJJQ.gif" /></figure><h4>Here are two more useful git commands:</h4><pre>$ <strong>git fetch<br>    </strong>AND<br>$ <strong>git merge</strong></pre><p>In the simplest terms, git fetch followed by a git merge equals a git pull. But then why do these exist?</p><p>When you use git pull, Git tries to automatically do your work for you. <strong>It is context-sensitive</strong>, so Git will merge any pulled commits into the branch you are currently working in. git pull <strong>automatically merges the commits without letting you review them first</strong>.</p><p>When you git fetch, Git gathers any commits from the target branch that do not exist in your current branch and <strong>stores them in your local repository</strong>. However, <strong>it does not merge them with your current branch</strong>. This is particularly useful if you need to keep your repository up to date, but are working on something that might break if you update your files. To integrate the commits into your master branch, you use git merge.</p><h3>One More Thing:</h3><pre>.gitignore</pre><p>So what is it?</p><p>.gitignore tells git which files (or patterns) it should ignore. It&#39;s usually used to avoid committing transient files from your working directory that aren&#39;t useful to other collaborators, such as compilation products, temporary files IDEs create, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NFtOjfz0NvNSwba7YCmDA.png" /></figure><p>So in the above example, files like __pycache__, .DS_Store are used by the system to store information for faster access. This is not useful for other collaborators. So we can tell git to ignore them by adding a .gitignore file.</p><p>Use the touch command to create the .gitignore file:</p><pre>$ touch .gitignore</pre><p>And you can add the following patterns to tell git to ignore such files.</p><pre>/*.cmake<br>/*.DS_Store<br>/.user<br>/build<br>etc. depending upon the files you want git to untrack</pre><h3>And that’s pretty much it for the basics. Stay tuned for Part 2 which will focus on Branch, Merge, Stash, Rebase, etc.</h3><h3>Peace Out ✌️</h3><p><strong>References :</strong></p><ul><li><a href="https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/">Adding an existing project to GitHub using the command line - User Documentation</a></li><li><a href="https://blog.github.com/2015-06-08-how-to-undo-almost-anything-with-git/">How to undo (almost) anything with Git</a></li><li><a href="https://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html">Git on the commandline - Don&#39;t be afraid to commit 0.3 documentation</a></li><li><a href="https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html">Git on the command line | GitLab</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3a2x1iJFJWc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3a2x1iJFJWc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3a2x1iJFJWc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1322c0a2d53b92e294795cda9d00fcc/href">https://medium.com/media/e1322c0a2d53b92e294795cda9d00fcc/href</a></iframe><p><a href="https://stackoverflow.com/questions/292357/what-is-the-difference-between-git-pull-and-git-fetch">What is the difference between &#39;git pull&#39; and &#39;git fetch&#39;?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da548267cc91" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/learn-the-basics-of-git-in-under-10-minutes-da548267cc91">Learn the Basics of Git in Under 10 Minutes</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>