<?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"><channel><title><![CDATA[braincells2pixels]]></title><description><![CDATA[Self-taught professional bit assembler.]]></description><link>https://braincells2pixels.blog</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 10:37:40 GMT</lastBuildDate><atom:link href="https://braincells2pixels.blog/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Fundamentals of Programming 4 of n]]></title><description><![CDATA[Here is where we left off

We created a program to compute the profit (or loss) we incur selling various fruits. We separated the data our program uses from the operations it performs. The data is captured in an array of arrays (lines 1 - 6). The ope...]]></description><link>https://braincells2pixels.blog/fundamentals-of-programming-4-of-n</link><guid isPermaLink="true">https://braincells2pixels.blog/fundamentals-of-programming-4-of-n</guid><category><![CDATA[programing]]></category><category><![CDATA[newbie]]></category><dc:creator><![CDATA[idispose]]></dc:creator><pubDate>Tue, 02 Mar 2021 00:58:07 GMT</pubDate><content:encoded><![CDATA[<p>Here is where we left off</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613840338983/EW1ZoOQci.png" alt="Screen Shot 2021-02-20 at 9.46.28 AM.png" /></p>
<p>We created a program to compute the profit (or loss) we incur selling various fruits. We separated the <code>data</code> our program uses from the <code>operations</code> it performs. The <code>data</code> is captured in an <code>array</code> of <code>arrays</code> (lines 1 - 6). The <code>operations</code> are on lines 8 - 12. The <code>data</code> for ALL the fruits is in the array named <code>fruits</code>. Inside the fruits array, we have an array for each fruit we sell. Each fruit array contains information or data for a kind of fruit. The data for fruit that we are interested in are the selling price of a fruit <code>[0]</code>, the purchase price of the fruit <code>[1]</code>, the number of fruits sold <code>[2]</code> and the name of the fruit <code>[3]</code>. <code>[]</code> is how we extract data for each fruit from the array. </p>
<p>How the data for each fruit is "encapsulated" in the fruit array is known to you and me. Because we created the program. If we hand this program to a friend, they have no idea how the data is arranged or what the program does or how it works. </p>
<p>There are a couple of ways in which we can make our program comprehensive. The simplest way is to add <code>comments</code> or <code>notes</code> to our program. <code>Comments</code> are lines of text that are legible to a fellow human but not to the computer. In addition, we need to tell the computer to not try to run our comments like it does real computer code. Different programming languages use different techniques to mark lines in a program as comments. <code>Python</code> uses <code>#</code>. <code>C#</code> uses <code>// and /* */</code>. Let's add some comments. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613998291951/BdkrdT6yN.png" alt="Screen Shot 2021-02-22 at 7.51.07 AM.png" /></p>
<p>Lines 1 - 5 are comments. Each line you want to exclude from being executed starts with the <code>#</code> character. </p>
<p>Adding comments sure does help in comprehension. However, you may have to refer back to the comments each time you are unsure which element of the array represents a piece of information. For example, if you need to extract the name of the fruit, you need to remember to use <code>[3]</code>. Would it not be easier to refer to the element by a name? You can consider the <code>array</code> as a <code>key-value</code> map. The <code>index</code> of an element is the <code>key</code> and the <code>item</code> at that <code>index</code> is the <code>value</code>. The <code>value</code> in the fruit array for the key<code>3</code> is the name of the fruit. Most programming languages offer a data type that allows you to store <code>key-value</code> pairs. Such a data type is called a <code>Dictionary</code> and is similar to a word dictionary. A typical dictionary is an order list of words, orders by alphabetical order, with meanings. The word is the key and the corresponding meaning(s) is the value. In <code>Python</code> dictionaries are created like shown below. </p>
<pre><code>fruitDictionary = {
    <span class="hljs-string">"name"</span> : <span class="hljs-string">"Apple"</span>,
    <span class="hljs-string">"Selling Price"</span> : 2,
    <span class="hljs-string">"Purchase Price"</span>: 1,
    <span class="hljs-string">"Number Sold"</span> : 5
}
</code></pre><p>And to extract an item from the dictionary, we use the name within <code>[]</code> similar to how we used indexes. </p>
<pre><code><span class="hljs-comment"># extract the name of the fruit</span>
fruitDictionary[<span class="hljs-string">"name"</span>]
</code></pre><p>Now let's change our code to use dictionaries instead of arrays. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1614511778181/qUx0f4Zbt.png" alt="Screen Shot 2021-02-28 at 6.29.18 AM.png" /></p>
<p>The program is more readable. Notice that we used an array (<code>fruits</code>) to store each fruit. Can we use a dictionary? Unfortunately not. This is because, a dictionary has to contain unique <code>key</code>s. A <code>key</code> may not repeat. If you think about it, it makes sense. A key be definition is a crucial piece of information that references a unique fruit. You can technically force the <code>fruits</code> dictionary to contain unique keys. But that goes against the principle of using the right tools for the right thing. In our case, we need a data structure to hold the list of fruits. An array is a perfect tool in this case. Next, we need a data structure that we can extract bits of fruit data for computation. An array can work but is not the right tool because it holds lot of implicit information. A dictionary is perfectly suited to hold explicit information and offer the ability to extract information by name instead of indexes.  </p>
<p>The syntax of extracting the keys and values from a dictionary in a loop differ from programming language to language. Here's how you do it in <code>python</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1614646111771/FTlGzsMBu.png" alt="Screen Shot 2021-03-01 at 7.48.17 PM.png" /></p>
<p>The <code>variables</code> to extract the <code>key</code> and <code>value</code> don't have to be named <code>key</code> and <code>value</code>. They can be more descriptive. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1614646260298/JNIOTSsUp.png" alt="Screen Shot 2021-03-01 at 7.50.45 PM.png" /></p>
<p>Much cleaner. Thus far, we have learned a few concepts in programming. We learned about <code>variables</code> and <code>loops</code>. We learned there are different types of <code>variables</code>, like <code>int</code>, <code>string</code>, <code>array</code> and <code>dictionary</code>. Each variable type is used to "encapsulate" information or data. Simple variables like <code>int</code> and <code>string</code> store simple values. Complex variables like <code>array</code> and <code>dictionary</code> store more pieces of information. Next up we will learn of another important concept. Stay tuned!</p>
]]></content:encoded></item><item><title><![CDATA[Fundamentals of Programming 3 of n]]></title><description><![CDATA[Here is where we left off. 

To compute the profit for each new fruit sold, we copy pasted lines 1 to 6, changes all apples to new fruit sold. Notice a pattern here? Check of the print_message variable. We are not creating a new variable for each new...]]></description><link>https://braincells2pixels.blog/fundamentals-of-programming-3-of-n</link><guid isPermaLink="true">https://braincells2pixels.blog/fundamentals-of-programming-3-of-n</guid><category><![CDATA[General Programming]]></category><category><![CDATA[newbie]]></category><dc:creator><![CDATA[idispose]]></dc:creator><pubDate>Sat, 20 Feb 2021 14:53:05 GMT</pubDate><content:encoded><![CDATA[<p>Here is where we left off. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613328476994/PSDH66_pj.png" alt="Screen Shot 2021-02-13 at 12.11.18 PM.png" /></p>
<p>To compute the profit for each new fruit sold, we copy pasted lines 1 to 6, changes all <code>apples</code> to <code>new fruit</code> sold. Notice a pattern here? Check of the <code>print_message</code> variable. We are not creating a new variable for each new fruit we sell by are reusing the same and changing its value. Can we do the same for an array. YES! </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613328828614/73omaSpGU.png" alt="Screen Shot 2021-02-14 at 1.53.32 PM.png" /></p>
<p>One thing to note here. The fruit array has different types of information. The first 3 are numbers and the 4th one is a string. Python allows you to do this, but not all programming languages do. The goal here is not teach you programming language nuances, but to teach you the core concepts. </p>
<p>Notice we changed the name of the variable from <code>apple</code> to <code>fruit</code>. This makes the code generic for any new fruit we sell. Now for Oranges and Peaches, we simply copy lines 1 to 6, changes the values in the array and the printed message. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613328985225/EO9TdFHuU.png" alt="Screen Shot 2021-02-14 at 1.56.09 PM.png" /></p>
<p>Now for each new fruit you want to sell, you need to change only 2 lines of code. </p>
<p>Although this is better, we lost a bit of readability in our program. Previously, the array variables were named <code>apple, orange, or peach</code>. Looking at the array you could tell that the information contained inside in the array belonged to a type of fruit. That information can only be gleaned by looking at the value of the <code>print_message</code> variable. Can we include the name of the fruit inside the array? Yes!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613329404989/hQlqRmWDIn.png" alt="Screen Shot 2021-02-14 at 2.03.08 PM.png" /></p>
<p>Look at the print message. It says <code>Profit Apples</code>. We have the information of what is sold in the array. Can we use that and build the print message without having to type it each time for a new fruit sold? </p>
<p>In mathematics the <code>+</code> symbol is used to add 2 numbers. In programming we can use the same symbol to add or <code>join</code> text together. If you have 2 string variables <code>variable1</code> with a value of <code>Hello</code> and <code>variable2</code> with a value of <code>World!</code> you can make the string <code>HelloWorld!</code> by "adding" <code>variable1</code> and <code>variable2</code> like this <code>print(variable1 + variable2)</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613329700219/gXWChelXz.png" alt="Screen Shot 2021-02-14 at 2.08.06 PM.png" /></p>
<p>Notice a space <code>` after the word</code>Profit` to make the printed message look like a regular statement. Now when you sell different fruits, you just copy lines 1 to 6 and change 1 line of code instead of 2. </p>
<p>Before we get to the next important concept, a short lead up. </p>
<p>A computer program exists to serve a purpose. In our example it is helping compute the profit or loss of a fruit sale transaction. The program uses the information it has to perform the computation. The information is often referred to as <code>data</code> and the computation as <code>operation(s)</code>. It is called operation because not all steps a program performs are pure mathematical computations. Some are decision tasks. </p>
<p>If you look at our code the information is available in the various <code>fruit arrays</code>. Line 3 is where we are processing the data (information) to get new information. It would be nice if we can separate out the data and the processing logic into different areas for better code readability. Remember the code we write is read by other programmers and we should strive to make is as readable as possible. Let's move all the data lines to the top of the program. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613403491815/d0URCbZYh.png" alt="Screen Shot 2021-02-15 at 10.37.52 AM.png" /></p>
<p>If you run the program you see <code>Peaches</code> printed out 3 times. We have a problem. What's happening is we are using a single array variable <code>fruit</code> created on <code>line 1</code> and immediately changing the values on lines <code>2 and 3</code>. Essentially, when the program gets to the processing part, it just sees <code>peaches</code>.</p>
<p>So what we need is a structure that can hold data for multiple fruits. You are a smart person. So you ask, can I create an <code>array</code> of <code>arrays</code>? A multi-dimensional array? </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613404038847/r8M2R6-uP.png" alt="Screen Shot 2021-02-15 at 10.46.54 AM.png" /></p>
<p>You already know how to extract elements of an array. But if you look at what's printed, the entire array is. For profit computations, we need individual elements of the array? How do you access that? Use another set of <code>[]</code> as shown on <code>line 10</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613404280171/-Pj9U9Mwh.png" alt="Screen Shot 2021-02-15 at 10.50.45 AM.png" /></p>
<p>To access other elements of the array containing data for <code>apple</code>, copy line 10 onto line 11 and change the values in the second <code>[]</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613404523896/xY-sJu9b7.png" alt="Screen Shot 2021-02-15 at 10.55.07 AM.png" /></p>
<p>Now that we have learned how to create multi-dimensional array and extract data from it, let's compute the profit for apples. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613428911394/21qqwdb7m.png" alt="Screen Shot 2021-02-15 at 10.55.07 AM.png" /></p>
<p>This code is similar to the one you created earlier. You are accessing the <code>array</code> for <code>apple</code> using <code>fruits[0]</code> and accessing various elements of the apple array via <code>fruits[0][0], fruits[0][1]</code> etc. </p>
<p>Onto oranges now. Copy lines 7 to 11 onto 13 and change all <code>fruits[0]</code> to <code>fruits[1]</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613581166246/Pp5YuP-Cb.png" alt="Screen Shot 2021-02-17 at 11.58.59 AM.png" /></p>
<p>And if you want to compute the profit for peaches, copy lines 7 to 11 onto 19 and change all <code>fruits[0]</code> to <code>fruits[2]</code>.  And as you add more fruits, you add another array to the <code>fruits</code> array with the data for the fruit and then copy paste the lines 1 to 11. </p>
<p>Wait a minute. This is unfair you say. The computer was supposed to help you do more work with less effort. What you have been doing so far for each new fruit is a lot of repetitive work. Why can't the computer handle the repetitive work? Isn't is supposed to be good at this? </p>
<p>What we want is an ability to repeatedly run lines for code for each fruit array in the fruits array. We don't care how many fruit arrays are in the fruits array. For each such array we want to run lines 7 to 11. What this allows us to do is, when we have a new fruit to sell, we just add it as another array in the fruits array and not make any more changes to program. </p>
<p>Welcome to <code>loops</code>. In computer programming, a <code>loop</code> is a concept where you ask the computer to run one or more lines of code repeatedly. You are asking the computer to "loop" over the lines of code inside the loop. You don't want to run the loop forever. You need a way to stop the loop. The action of stopping the loop is often called <code>terminating the loop</code>. </p>
<p>Each programming language has its own loop construct, but most of them are similar. How you write the code, often called <code>the syntax</code>, might differ from one programming language to another, similar to how you express concepts in different human languages. Here is how you create a loop in <code>Python</code>. Pretty straightforward. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613831672088/mJoJ2y1Y4.png" alt="Screen Shot 2021-02-20 at 9.33.46 AM.png" /></p>
<p>Don't sweat the <code>syntax</code> too much. We are here to learn concepts. What the code above is doing is this. For each fruit in our fruits <code>array</code> we print out the <code>fruit</code> array. So now when you have a new fruit all you have to do is add it to the array and the new fruit will be printed. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613831837501/-WRgVSj8d.png" alt="Screen Shot 2021-02-20 at 9.37.00 AM.png" /></p>
<p>Armed with that, let's replace the <code>print</code> statement with code to compute the profit. Remember, "inside" the loop you are handed a fruit array. So you don't need <code>[][]</code>. <code>fruit</code> is an array of single dimension. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613832404433/KT2jskjUX.png" alt="Screen Shot 2021-02-20 at 9.46.28 AM.png" /></p>
<p>Line 9 - 12 should be familiar to you. </p>
<p>Next up we will try to make this code more readable and remove some of the ambiguity. Stay Tuned!</p>
]]></content:encoded></item><item><title><![CDATA[Fundamentals of Programming 2 of n]]></title><description><![CDATA[Let's sell some oranges too!

 Now that you made tons of money selling apples, you decide to expand your business and want to sell oranges too. Here is where we left off.

The easiest way to add Orange profit computation is to copy lines 1 to 9 and p...]]></description><link>https://braincells2pixels.blog/fundamentals-of-programming-2-of-n</link><guid isPermaLink="true">https://braincells2pixels.blog/fundamentals-of-programming-2-of-n</guid><category><![CDATA[General Programming]]></category><category><![CDATA[newbie]]></category><dc:creator><![CDATA[idispose]]></dc:creator><pubDate>Sat, 13 Feb 2021 17:20:30 GMT</pubDate><content:encoded><![CDATA[<p><strong>Let's sell some oranges too!
</strong></p>
<p> Now that you made tons of money selling apples, you decide to expand your business and want to sell oranges too. Here is where we left off.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612454201767/celf-srsC.png" alt="Screen Shot 2021-02-03 at 8.33.06 PM.png" /></p>
<p>The easiest way to add Orange profit computation is to copy lines 1 to 9 and paste on line 11. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612744699350/N3CjrXQiz.png" alt="Screen Shot 2021-02-07 at 7.37.47 PM.png" /></p>
<p>If you look at the code you created you can't really tell if the first computation is for apples or oranges. The variable for the number sold says <code>number_of_apples_sold</code>. For both apples and oranges. Also, when you run the program, you see Profit 2 times and you don't know which is which. These are easy to fix. Let's change the variable name and the message printed.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612745589582/-Vdm_XZ-e.png" alt="Screen Shot 2021-02-07 at 7.52.41 PM.png" /></p>
<p>Much better. The program prints clear messages. </p>
<p>You make even more money and are ready to sell Peaches and even dragon fruit. You know the drill. Copy lines 1 to 9. Change the variable name <code>number_of_apples_sold</code> to <code>number_of_peaches_sold</code> and <code>number_of_dragon_fruits_sold</code>, change the messages to <code>Profit - Peaches</code> and <code>Profit - Dragonfruits</code>. </p>
<p>But, you are a smart cookie and realize the futility of the above exercise as you become richer and add more fruits to sell. Technically you can continue copy pasting code. The program will work, but managing so many lines of code becomes really really hard and the chances of making a mistake is very high. </p>
<p>One trick you can employ is programming is to determine if there are any common patterns and then figure out if you can combine them into a repeatable set of code. </p>
<p>So what are we selling? Fruits. We buy a fruit at a price and sell them in certain quantities at a price for each. What are we computing? Profit. More specifically, profit of a sale. A transaction that has certain characteristics. Each sale has a fruit that we sell. To determine the profit (or loss) of a transaction, you need certain pieces of information. In the sale transaction there are 4 important pieces of information. </p>
<ol>
<li>Sale Price</li>
<li>Purchase Price</li>
<li>Number of fruits sold</li>
<li>Fruit Sold (name of the fruit)</li>
</ol>
<p>A transaction is a name we give to the action of selling fruits. It's an abstract concept. We recognize that a transaction has certain properties. We identified 4 such properties above. There probably are more, and they depend on what your needs are. In the current scenario, all we are trying to determine is the profit of a transaction. </p>
<p>In the current incarnation of our program we used 3 variables to represent each of the first 3 properties (sale price, purchase price and number of fruits sold) explicitly and the name was used implicitly. First set represents apples, second oranges, and so on. So far we have encountered 2 types of variables. One that holds numeric values and one that hold text or string values. Referring back to we see that for every fruit sold, we need a set of 3 pieces of information. We "encoded" this in 3 variables. Can we encode the information in a single variable? </p>
<p>The answer is YES WE CAN! </p>
<p>People, meet Mr. Array. In <code>Python</code> you create a variable of the type <code>array</code> by using the square brackets <code>[]</code> like this</p>
<p><code>arrayVariable = []</code></p>
<p><code>arrayVariable</code> is the name of your variable. <code>[]</code> represents an empty array. We have nothing in it. Let's put some items in it. For our profit computation we add the 3 pieces of information as 3 items to the array. The items in the array are called <code>elements</code> of an array. </p>
<p><code>apple = [2, 1, 10]</code></p>
<p>In the example above we are creating an <code>array variable</code> named <code>apple</code>. The first element <code>2</code> represents the <code>sale price</code>. The second element <code>3</code> represents the <code>purchase price</code> and the third element <code>10</code> represents <code>number of apples sold</code>. Let's check out how the program looks. Replace all the lines in your program on Repl.it as shown below. You are simply printing the <code>array</code> your created. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613234696192/UJQFtrVRL.png" alt="Screen Shot 2021-02-13 at 11.44.34 AM.png" /></p>
<p>To compute the profit, earlier we used variables. The formula for profit works with individual pieces of information. But now we have "encoded" the information as 3 elements of an array. How do we extract the individual pieces? You do so by extracting the item based on its position in the array. </p>
<p>A short detour. The decimal number system is based on 10 base digits. <code>0 to 9</code>. In most programming languages, positional counting is done starting from 0 instead of 1 (like IRL). </p>
<p>Getting back to our array, it has 3 elements. The 1st element <code>2</code> is at <code>position 0</code>. The 2nd element <code>1</code> is at <code>position</code>1 and the 3rd element <code>10</code> is at position 2. The total number of elements in the array is <code>3</code> but there's nothing at <code>position 3</code>. The maximum position in the array is 1 less than the total number of items in the array. The number of elements in the array is also referred to as its <code>length</code>. In our example the length of the <code>array apple</code> is <code>3</code>.</p>
<p>To extract elements from the array, you use the array name followed by the square brackets <code>[]</code> and use the position value inside the <code>[]</code>. For example to extract the first element your write <code>apple[0]</code>. Let's modify our program to print each element of the array. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613235372773/FH-sLRjyN.png" alt="Screen Shot 2021-02-13 at 11.55.58 AM.png" /></p>
<p>Now that we learned to extract the individual pieces of information we can easily compute the profit like this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613235862599/Jcv_VwfYO.png" alt="Screen Shot 2021-02-13 at 12.03.56 PM.png" /></p>
<p>Let's update the program to compute profits for oranges and peaches. Copy lines <code>1 - 6</code> onto line 8. Change <code>apple</code> to <code>orange</code>. And again onto line 15 and change <code>apple</code> to <code>peach</code>. Your program should look like this.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1613236291787/H0U8503Lp.png" alt="Screen Shot 2021-02-13 at 12.11.18 PM.png" /></p>
<p>The above method of copy pasting will work for a handful of fruits you sell. But even that is tedious. You have change several lines of code and if you make a mistake and forget to change an apple to an orange, your computation will be wrong. </p>
<p>In the next post let's see how we can reduce the number of line of code that needs to changes for each new fruit we add. Stay tuned!</p>
]]></content:encoded></item><item><title><![CDATA[Fundamentals of Programming 1 of n]]></title><description><![CDATA[This series is for absolute beginners. No assumption is made that you have any programming knowledge. I only ask you to be open to using  Repl.it a simple online IDE (integrated Development Environment). I ask you to not be intimidated. Hopefully you...]]></description><link>https://braincells2pixels.blog/fundamentals-of-programming-1-of-n</link><guid isPermaLink="true">https://braincells2pixels.blog/fundamentals-of-programming-1-of-n</guid><category><![CDATA[programing]]></category><category><![CDATA[#beginners #learningtocode #100daysofcode]]></category><category><![CDATA[newbie]]></category><dc:creator><![CDATA[idispose]]></dc:creator><pubDate>Thu, 04 Feb 2021 01:43:39 GMT</pubDate><content:encoded><![CDATA[<p>This series is for absolute beginners. No assumption is made that you have any programming knowledge. I only ask you to be open to using  <a target="_blank" href="https://repl.it/">Repl.it</a> a simple online IDE (integrated Development Environment). I ask you to not be intimidated. Hopefully you can enjoy the ride. </p>
<p>Programming or coding is a means to an end. You don't write a computer program without a purpose. Most programming 101-level books jump into listing various things in programming and if you are not immersed in the world already, you feel lost. It's not you. It's them and how the information in presented. </p>
<p>Let's start with the problem statement. </p>
<p>You sells apples and want to figure out the profit (or loss) you are making. And you want to write a computer program to help you determine the profit/loss. </p>
<p>The first step is to understand the problem and come up with a solution. In programming parlance, the solution is often referred to as an algorithm. So what's our algorithm? From basic math/business class, profit is how much money you are left with after you sell something. If you sold the apple for more than what you bought it for, you make a profit. If you sell for less, you take a loss. </p>
<p>The algorithm boils down to this. </p>
<ol>
<li>Note the purchase price</li>
<li>Note the selling price</li>
<li>profit or loss per apple sold = selling price - purchase price</li>
<li>Multiply the number from step 3 with the number of apples sold</li>
</ol>
<p>Let's write some code. Don't be intimated. You are in command. The computer exists to serve you. </p>
<p>Login to your Repl.it account. You should see a screen similar to this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612356390415/JsdYz-G1L.png" alt="Screen Shot 2021-02-03 at 7.45.06 AM.png" /></p>
<p>Click on <code>+ New Repl</code> on the top left. You should see a popup like below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612356633351/gordixgcN.png" alt="Screen Shot 2021-02-03 at 7.48.56 AM.png" /></p>
<p>Select <code>Python</code> from the first drop down. Click <code>Create repl</code> And this brings you to the IDE like the one shown below</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612357138092/IOSHWyfNF.png" alt="Screen Shot 2021-02-03 at 7.50.06 AM.png" /></p>
<p>Do not be intimidated. You don't need to understand anything that's specific to <code>Python</code> or programming. This IDE is a means to an end and our goal is to learn concepts. </p>
<p>To help you get familiar with the controls in the IDE, the most relevant ones for our discussion, let's perform the standard programming ritual of printing <code>Hello World!</code></p>
<p>In the middle part of the screen where the tab title says <code>main.py</code> type in the following
<code>print("Hello World!")</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612358115547/xV-qifi7L.png" alt="Screen Shot 2021-02-03 at 8.14.55 AM.png" /></p>
<p>Click the <code>Run</code> button and you should see <code>Hello World!</code> on the right side. </p>
<p>You are a programmer!!</p>
<p>Again, don't worry if you don't understand anything you did at this point. This is just a ritual. And like most rituals, we just perform it just because <code>that's the way</code>! Just remember the statement <code>print</code> prints the results to the right part of the screen.</p>
<p>Now, let's get on with why we are here. We want to write a program that computes the profit (or loss) of selling apples. </p>
<p>We buy apples at $1 each and sell them at $2 each (yeah! 100% profit!). What is the profit when we sell 2 apples? </p>
<p>If this were a math assignment, you would write it out as </p>
<p><code>(2 - 1 ) x 2</code></p>
<p>In programming the <code>*</code> character is used to denote multiplication. So this becomes</p>
<p><code>(2 - 1) * 2</code></p>
<p>Let's program!</p>
<p>Replace <code>"Hello World!"</code> with <code>(2 - 1) * 2</code> and click <code>Run</code>. You should see <code>2</code> printed on the right.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612359693764/38GJwrBM4.png" alt="Screen Shot 2021-02-03 at 8.41.12 AM.png" /></p>
<p>Without the context if anyone looks at <code>2</code> in the right most pane, they have no idea what it represents. Let's correct that. Add a <code>print("Profit")</code> statement on line 1. Now when you run the program it will display <code>Profit</code> and <code>2</code> on two separate lines.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612362207930/DqQj38X40.png" alt="Screen Shot 2021-02-03 at 9.23.01 AM.png" /></p>
<p>Much better!</p>
<p>Next, let's say your friend also wants in on the fun. They say what if I sell 5 apples. You say, fine. Change the <code>2</code> to <code>5</code>. When your friends looks at the program they cannot immediately figure out which <code>2</code> to change. Is it the first one or the second one? You know which one because you created the program. However, if it was a complex formula pretty soon even you won't be able to tell the various numbers apart.  </p>
<p>We need to make the program clearer. More Readable. Anyone should be able to look at the code and deduce what's going on. </p>
<p>If you formulate the problem as a mathematical formula (remember algebra?), you express it like so
<code>pl = (s - p) * n</code> where <code>pl</code> represents <code>profit or loss</code>, <code>s</code> represents <code>sale price</code>, <code>p</code> represents <code>purchase price</code> and, <code>n</code> represents the number of apples sold. </p>
<p>The formula <code>pl = (s - p) * n</code> is not clear without a legend describing what each alphabet represents. You can probably make is clear like so</p>
<p><code>profit_or_loss = (sale_price - purchase_price) * number_of_apples_sold</code></p>
<p> You just learned one of the core concepts of programming. <code>variables</code>. In mathematical formula above <code>pl</code>, <code>s</code>, <code>p</code> and <code>n</code> are variables. They are names we attribute to things we want to represent in a formula. Anyone who wants to solve the formula simply replaces variables with values they want to plug in. When programming, it is a best practice to use meaningful words as variables instead of single characters like you do in mathematical formulas. </p>
<p>Let's rewrite our program with variables. Type the lines as shown below. We will get to the red squiggles later.  </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612400960193/6yzt0mP4U.png" alt="Screen Shot 2021-02-03 at 8.08.36 PM.png" /></p>
<p>Click the <code>Run</code> button. Uh! Oh! Error!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612401136768/efH6GseFB.png" alt="Screen Shot 2021-02-03 at 8.11.44 PM.png" /></p>
<p>What's going on? We are using <code>Python</code> as the programming language and <code>Python</code> doesn't understand that you want to create variables. Each programming language has it's own rules on how to create variables. In <code>Python</code> you make your intent known by giving the variable a value. The act of giving a variable a value is called an <code>assignment</code>. You are assigning a value to a variable. </p>
<p>Variables can "hold" different types of information. Since we are dealing with numbers we assign numeric values to our variables. Add the assignment like so</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612401737163/vfUUi25hl.png" alt="Screen Shot 2021-02-03 at 8.18.04 PM.png" /></p>
<p>Click <code>Run</code>. Bingo! Now we are back in business. Assign different values to the variables and check out the result. You can even assign values like <code>1.25</code> or <code>2.75</code>. Can variables hold non-numbers? Of course they can. These types of values are called strings and are usually enclosed with <code>''</code> or <code>""</code>. Remember the ritual? We had <code>print("Hello World!")</code>. "Hello World!" is a string. Make the change like shown below to add a string variable to your program. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1612402419155/fwFJAQyeJ.png" alt="Screen Shot 2021-02-03 at 8.33.06 PM.png" /></p>
<p>In the following posts we will work on expanding the program and learn other core concepts of programming. Stay tuned! </p>
]]></content:encoded></item><item><title><![CDATA[Introducing the Hackshops Programmable Robot]]></title><description><![CDATA[Recently, I was trying to help a High School student with their AP computer science course. It is unfortunate that the curriculum uses Java as the programming language and the textbook chosen is as dry as it can be. No wonder a large number of High S...]]></description><link>https://braincells2pixels.blog/introducing-the-hackshops-programmable-robot</link><guid isPermaLink="true">https://braincells2pixels.blog/introducing-the-hackshops-programmable-robot</guid><category><![CDATA[programming languages]]></category><dc:creator><![CDATA[idispose]]></dc:creator><pubDate>Sat, 17 Oct 2020 18:19:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1602958361273/gBI1ZrY9K.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Recently, I was trying to help a High School student with their AP computer science course. It is unfortunate that the curriculum uses Java as the programming language and the textbook chosen is as dry as it can be. No wonder a large number of High School kids are turned off. Almost all computer programming books follow the same basic pattern. Start with chapter on variables. Move to conditionals, loops, and graduate to functions and classes. All Theory and no fun at all. None. Examples make no sense and do not reinforce any concepts. You may be able to type programs on the computer but have no clue why you need variables or what conditionals are used for. </p>
<p>Having mentored at local  <a target="_blank" href="https://girlswhocode.com/">Girls Who Code</a> club, I quickly learned teaching kids programming needs a completely different approach. If you are intrigued by programming, you will suffer thru the dry chapters, but that approach does not work for most people. </p>
<p>To help kids, and anyone interested in learning programming,  <a target="_blank" href="https://hackshops.org">HackShops.org</a> built a programmable robot. HackShops.org sincerely believes that a hands-on approach, learn-by-doing is the best way to learn the core concepts of programming. HackShops.org has successfully used these robots to introduce middle-school kids to programming and it has been very successful. </p>
<p>You can order one for yourself from  <a target="_blank" href="https://gumroad.com/l/piHYG">Gumroad</a> .  </p>
<p>The pre-built kit comes with everything you need to get started. Just add a Raspberry-Pi, a powerpack to power the Pi and a 9V battery to power the motors and you are off to the races. </p>
<p>In subsequent posts, I'll walk you through setting up the robot and how to program it. Stay tuned! </p>
]]></content:encoded></item><item><title><![CDATA[Machine Learning With A Bird Feeder 1 of n]]></title><description><![CDATA[TLDR; I am no  Brandon Rohrer  and this is not an  End-To-End-ML Course .
Around the time the Covid-19 lock downs started, I went down to the basement with an order from the boss to clean things up. Like Aladdin discovering the magic lamp, I found th...]]></description><link>https://braincells2pixels.blog/machine-learning-with-a-bird-feeder-1-of-n</link><guid isPermaLink="true">https://braincells2pixels.blog/machine-learning-with-a-bird-feeder-1-of-n</guid><category><![CDATA[Machine Learning]]></category><category><![CDATA[Raspberry Pi]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[idispose]]></dc:creator><pubDate>Mon, 21 Sep 2020 13:26:30 GMT</pubDate><content:encoded><![CDATA[<p>TLDR; I am no  <a target="_blank" href="https://twitter.com/_brohrer_">Brandon Rohrer</a>  and this is not an  <a target="_blank" href="https://end-to-end-machine-learning.teachable.com/">End-To-End-ML Course</a> .</p>
<p>Around the time the Covid-19 lock downs started, I went down to the basement with an order from the boss to clean things up. Like Aladdin discovering the magic lamp, I found this beautiful pineapple bird feeder. Ordered some bird feed and hung it out on the deck. Surprisingly, it took a couple of days before the birds started showing up. And oh boy! What a riot once they did. We had great time trying to identify the birds and refilling the feeder as soon as it ran low. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1600694832216/fp_m0mn3S.png" alt="BirdFeeder.png" /></p>
<p>We took a couple of pictures and tried to identify the birds. This got me thinking. Why not hook up a camera and have it identify the birds? Had a spare <a target="_blank" href="https://wyze.com/wyze-cam.html">Wyze</a> Cam. Unfortunately this camera did not capture pictures with good resolution. In addition, I don't have API level access to the pictures. </p>
<p>The next step was to build my own camera setup, and what better board than a Raspberry Pi? This is one of the most versatile computer boards. I had an older version of Pi Zero without camera access. So bought a new <a target="_blank" href="https://www.pishop.us/product/raspberry-pi-zero-w/">Pi Zero</a>. The next problem I ran into was, the camera cable I had was not compatible. Another round of Amazon shopping. </p>
<p>I now have a programmable camera. In a series of blog posts, I intend to capture my journey of implementing a Bird Identifier system. I am no trained Data Scientist. These posts will be light on math (if any at all), but will capture the essence of building a pipeline using resources from Azure, AWS or GCP as appropriate. The programming language I intend to use is Python (I am a newbie). I'll be collecting my thoughts here on why I decided to do what I did, lessons learned, etc. Each post will focus on one aspect of the problem and the corresponding solution. In addition, I also intend to stream some of the work on <a target="_blank" href="https://twitch.tv\HackShops">Twitch</a></p>
<p>I hope you will join me on this journey. Stay tuned!</p>
]]></content:encoded></item><item><title><![CDATA[Announcing programming basics stream]]></title><description><![CDATA[I am launching a new twitch.tv stream to help newbies understand the concepts of programming. We have put together a Raspberry Pi based robot to help reinforce the core concepts. Most programming books that teach a computer language have several dry ...]]></description><link>https://braincells2pixels.blog/announcing-programming-basics-stream</link><guid isPermaLink="true">https://braincells2pixels.blog/announcing-programming-basics-stream</guid><dc:creator><![CDATA[idispose]]></dc:creator><pubDate>Tue, 11 Aug 2020 01:28:03 GMT</pubDate><content:encoded><![CDATA[<p>I am launching a new twitch.tv stream to help newbies understand the concepts of programming. We have put together a Raspberry Pi based robot to help reinforce the core concepts. Most programming books that teach a computer language have several dry chapters trying to introduce variables, looks, functions etc which is easily palatable unless you are highly motivated or your job is on the line. </p>
<p>With the HackShops robot, I&#39;ll be teaching programming form an entirely different angle. Computer programs are a means to an end.</p>
<p>I hope you will join me on  <a target='_blank' rel='noopener'  href="https://twitch.tv/Hackshops">https://twitch.tv/Hackshops</a>  every Thursday 7PM-8PM US EDT. The first stream is on August 13th 2020. </p>
]]></content:encoded></item><item><title><![CDATA[Do you have the guts to do agile?]]></title><description><![CDATA[Re-posting from my previous blog. Minor edits. Still relevant.
Agile and its variation are firmly entrenched. Especially in IT services. Don't get me wrong. This post is not dissing the practice. If done right and pragmatically, Agile is the way to g...]]></description><link>https://braincells2pixels.blog/do-you-have-the-guts-to-do-agile</link><guid isPermaLink="true">https://braincells2pixels.blog/do-you-have-the-guts-to-do-agile</guid><dc:creator><![CDATA[idispose]]></dc:creator><pubDate>Tue, 11 Aug 2020 01:16:41 GMT</pubDate><content:encoded><![CDATA[<p>Re-posting from my previous blog. Minor edits. Still relevant.</p>
<p>Agile and its variation are firmly entrenched. Especially in IT services. Don&#39;t get me wrong. This post is not dissing the practice. If done right and pragmatically, Agile is the way to go. The theory is good. No not just good, but great! The issue is practice. It is one thing to come up with a good idea, but without execution, that&#39;s what it is - a good idea. End of story.</p>
<p>In my opinion,  agile scrum does not work. Having made that provocative statement, let me qualify it. Agile does not work if the team practicing it does not have guts. You need passionate, self-motivated people to make agile a success.  Else, all you are doing is going fast nowhere and telling stories. </p>
<p>Here are some of the tenets of running an Agile team</p>
<ol>
<li><p>An agile team may not have a team lead
In theory this is good. If everyone is equally motivated and smart, you don&#39;t need a task assigner or team leader. The team understands the needs and just gets it done. Team members look at the scrum board, pull tasks, swarm around blocks and keep moving the stones up the pyramids. Great things are accomplished by great teams. However, there are only so many good people. The minute you put more than 2 mediocre people, you bring in politics.  People start finding all kinds of excuses to why something cannot or could not be done. For mediocre people only sticks work.</p>
</li>
<li><p>Every team member is accountable to the team. Everyone is empowered.
Again, a great idea. If everyone is honest, no one will feel threatened. Smart people treat one another with respect. To use the cliche, with empowerment comes responsibility. Most agile teams start out to have daily stand-up meetings. However these meetings pretty soon devolve into status meetings which waste everyone&#39;s time. Everyone shows up. Blurts out what they did yesterday, what they might do today and there never is any block. None whatsoever. No one questions anything. Just get it over with. When it&#39;s everyone&#39;s responsibility to be accountable and call out, it becomes no one&#39;s responsibility. You scratch my back and I&#39;ll scratch yours. This is why you need gutsy team members. Team members who have the guts to call out others and team  members who have the guts to take criticism.</p>
</li>
<li><p>An agile process will weed out weak players because process shines the light on such players
For this to really work, you need honest, motivated people. Put together a bunch of mediocre people, and you will get what you  measure. Everyone will start working toward satisfying the measurements. The manager uses a magic formula to deem that a team of 5 people can deliver X number of story points. Weak teams will tell stories that magically add up to X. Writing a Hello World program will magically get an &quot;8&quot; and you add 8 more such story points, you already exceed X. Now you are looking awesome. Because mediocre team players are good at playing politics, everyone scratches everyone&#39;s back. Dissenting voices will be frowned upon and soon those dissenting will become demotivated and maybe move on. Everyone wins.</p>
</li>
<li><p>5-6 is the ideal number for the team size
This one size fits all teams in a large project is not fair. Some team members work well and some don&#39;t. Human dynamics and interactions are complex expecially when survival is at stake as is the case with mediocre team members. So for some teams, 3 may be the optimal size where as 6 may work better with another. Teams are supposed to be dynamic in constitution but that will work only if we have a bunch of top-notch folks</p>
</li>
</ol>
<p>So, do you have the guts to do agile? I hope so. And, good luck. </p>
]]></content:encoded></item><item><title><![CDATA[The day my boss caught me lying!]]></title><description><![CDATA[TLDR;
Multi-tasking is a myth. If you are asked to review anything, keep notes. 
This is an incident from a couple of jobs ago. I used to work for a smart guy. I had a suspicion I wasn't completely trusted. Trust but verify. Fair enough. 
I was juggl...]]></description><link>https://braincells2pixels.blog/the-day-my-boss-caught-me-lying</link><guid isPermaLink="true">https://braincells2pixels.blog/the-day-my-boss-caught-me-lying</guid><dc:creator><![CDATA[idispose]]></dc:creator><pubDate>Tue, 28 Jul 2020 13:43:40 GMT</pubDate><content:encoded><![CDATA[<p>TLDR;
Multi-tasking is a myth. If you are asked to review anything, keep notes. </p>
<p>This is an incident from a couple of jobs ago. I used to work for a smart guy. I had a suspicion I wasn&#39;t completely trusted. Trust but verify. Fair enough. </p>
<p>I was juggling multiple projects and was amidst a personal crisis as well. But none of those are excuses. Just want to set the context. </p>
<p>The boss walked in handed an article he had drafted and asked me to review and provide feedback. It was a short one. Don&#39;t remember the topic. The boss is a good writer so there were only trivial suggestions. Besides I was distracted. And I thought I would remember the changes when asked.</p>
<p>Couple days later boss asks for feedback. I said &quot;Look good&quot;. </p>
<p>Boss: &quot;Do you agree with the content&quot;
I: &quot;Yes, more or less&quot; &lt;- note flippant, distracted commet
Boss: &quot;Which parts do you not agree&quot;
I: Deer in headlights</p>
<p>To this day I remember the look on his face. And I realized, he thinks I lied. To his credit, he was gracious enough and said &quot;why don&#39;t you review it once again and send me your feedback&quot;.</p>
<p>Lesson learned. </p>
]]></content:encoded></item></channel></rss>