<?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 Adrian on Medium]]></title>
        <description><![CDATA[Stories by Adrian on Medium]]></description>
        <link>https://medium.com/@adrian_v?source=rss-124201dddc8e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9vl98G4Wa3HiRUTslbyrDQ.jpeg</url>
            <title>Stories by Adrian on Medium</title>
            <link>https://medium.com/@adrian_v?source=rss-124201dddc8e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 21:20:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adrian_v/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[JavaScript is like Python]]></title>
            <link>https://medium.com/codeguppy/javascript-is-like-python-4c8a40d84bac?source=rss-124201dddc8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c8a40d84bac</guid>
            <dc:creator><![CDATA[Adrian]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 02:43:58 GMT</pubDate>
            <atom:updated>2024-04-04T02:43:58.015Z</atom:updated>
            <content:encoded><![CDATA[<p>This article presents a comparison between the syntax and fundamental programming constructs of JavaScript and Python. It aims to highlight similarities in how basic programming concepts are implemented across these two popular programming languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*LiH-oTnZHR7S8G-MqZ7s8w.jpeg" /></figure><p>While both languages share many commonalities, making it easier for developers to switch between them or understand the other&#39;s code, there are also distinct syntactical and operational differences that one should be aware of.</p><p>It&#39;s important to approach this comparison with a light-hearted perspective and not to overemphasize the likeness or differences between JavaScript and Python. The intention is not to declare one language superior to the other but to provide a resource that can help coders who are familiar with Python to understand and transition to JavaScript more easily.</p><h3>Hello World</h3><p><strong>JavaScript</strong></p><pre>// In codeguppy.com environment<br>println(&#39;Hello, World&#39;);<br><br>// Outside codeguppy.com<br>console.log(&#39;Hello, World&#39;);</pre><p><strong>Python</strong></p><pre>print(&#39;Hello, World&#39;)</pre><h3>Variables and Constants</h3><p><strong>JavaScript</strong></p><pre>let myVariable = 100;<br><br>const MYCONSTANT = 3.14159;</pre><p><strong>Python</strong></p><pre>myVariable = 100<br><br>MYCONSTANT = 3.14159</pre><h3>String Interpolation</h3><p><strong>JavaScript</strong></p><pre>let a = 100;<br>let b = 200;<br><br>println(`Sum of ${a} and ${b} is ${a + b}`);</pre><p><strong>Python</strong></p><pre>a = 100<br>b = 200<br><br>print(f&#39;Sum of {a} and {b} is {a + b}&#39;)</pre><h3>If Expression / Statement</h3><p><strong>JavaScript</strong></p><pre>let age = 18;<br><br>if (age &lt; 13) <br>{<br>    println(&quot;Child&quot;);<br>} <br>else if (age &lt; 20) <br>{<br>    println(&quot;Teenager&quot;);<br>} <br>else <br>{<br>    println(&quot;Adult&quot;);<br>}</pre><p><strong>Python</strong></p><pre>age = 18<br><br>if age &lt; 13:<br>    print(&quot;Child&quot;)<br>elif age &lt; 20:<br>    print(&quot;Teenager&quot;)<br>else:<br>    print(&quot;Adult&quot;)</pre><h3>Conditionals</h3><p><strong>JavaScript</strong></p><pre>let age = 20;<br>let message = age &gt;= 18 ? &quot;Can vote&quot; : &quot;Cannot vote&quot;;<br>println(message);  // Output: Can vote</pre><p><strong>Python</strong></p><pre>age = 20<br>message = &quot;Can vote&quot; if age &gt;= 18 else &quot;Cannot vote&quot;<br>print(message)  # Output: Can vote</pre><h3>Arrays</h3><p><strong>JavaScript</strong></p><pre>// Creating an array<br>let myArray = [1, 2, 3, 4, 5];<br><br>// Accessing elements<br>println(myArray[0]);  // Access the first element: 1<br>println(myArray[3]);  // Access the fourth element: 4<br><br>// Modifying an element<br>myArray[2] = 30;  // Change the third element from 3 to 30<br><br>// Adding a new element<br>myArray.push(6);  // Add a new element to the end</pre><p><strong>Python</strong></p><pre># Creating a list to represent an array<br>my_array = [1, 2, 3, 4, 5]<br><br># Accessing elements<br>print(my_array[0])  # Access the first element: 1<br>print(my_array[3])  # Access the fourth element: 4<br><br># Modifying an element<br>my_array[2] = 30  # Change the third element from 3 to 30<br><br># Adding a new element<br>my_array.append(6)  # Add a new element to the end</pre><h3>ForEach</h3><p><strong>JavaScript</strong></p><pre>let fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;, &quot;date&quot;];<br><br>for(let fruit of fruits)<br>    println(fruit);</pre><p><strong>Python</strong></p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;, &quot;date&quot;]<br><br>for fruit in fruits:<br>    print(fruit)</pre><h3>Dictionaries</h3><p><strong>JavaScript</strong></p><pre>// Creating a dictionary<br>fruit_prices = {<br>    apple: 0.65,<br>    banana: 0.35,<br>    cherry: 0.85<br>};<br><br>// Accessing a value by key<br>println(fruit_prices[&quot;apple&quot;]);  // Output: 0.65</pre><p><strong>Python</strong></p><pre># Creating a dictionary<br>fruit_prices = {<br>    &quot;apple&quot;: 0.65,<br>    &quot;banana&quot;: 0.35,<br>    &quot;cherry&quot;: 0.85<br>}<br><br># Accessing a value by key<br>print(fruit_prices[&quot;apple&quot;])  # Output: 0.65</pre><h3>Functions</h3><p><strong>JavaScript</strong></p><pre>function addNumbers(a, b) <br>{<br>    return a + b;<br>}<br><br>let result = addNumbers(100, 200);<br>println(&quot;The sum is: &quot;, result);</pre><p><strong>Python</strong></p><pre>def add_numbers(a, b):<br>    return a + b<br><br>result = add_numbers(100, 200)<br>print(&quot;The sum is: &quot;, result)</pre><h3>Tuple Return</h3><p><strong>JavaScript</strong></p><pre>function getCircleProperties(radius) <br>{<br>    const area = Math.PI * radius ** 2;<br>    const circumference = 2 * Math.PI * radius;<br><br>    return [area, circumference];  // Return as an array<br>}<br><br>// Using the function<br>const [area, circumference] = getCircleProperties(5);<br><br>println(`The area of the circle is: ${area}`);<br>println(`The circumference of the circle is: ${circumference}`);</pre><p><strong>Python</strong></p><pre>import math<br><br>def getCircleProperties(radius):<br>    &quot;&quot;&quot;Calculate and return the area and circumference of a circle.&quot;&quot;&quot;<br>    area = math.pi * radius**2<br>    circumference = 2 * math.pi * radius<br>    return (area, circumference)<br><br># Using the function<br>radius = 5<br>area, circumference = getCircleProperties(radius)<br><br>print(f&quot;The area of the circle is: {area}&quot;)<br>print(f&quot;The circumference of the circle is: {circumference}&quot;)</pre><h3>Variable number of arguments</h3><p><strong>JavaScript</strong></p><pre>function sumNumbers(...args) <br>{<br>    let sum = 0;<br>    for(let i of args)<br>        sum += i;<br>    return sum;<br>}<br><br>println(sumNumbers(1, 2, 3));<br>println(sumNumbers(100, 200));</pre><p><strong>Python</strong></p><pre>def sum_numbers(*args):<br>    sum = 0<br>    for i in args:<br>        sum += i<br>    return sum<br><br>print(sum_numbers(1, 2, 3))<br>print(sum_numbers(100, 200))</pre><h3>Lambdas</h3><p><strong>JavaScript</strong></p><pre>const numbers = [1, 2, 3, 4, 5];<br><br>// Use map to apply a function to all elements of the array<br>const squaredNumbers = numbers.map(x =&gt; x ** 2);<br><br>println(squaredNumbers);  // Output: [1, 4, 9, 16, 25]</pre><p><strong>Python</strong></p><pre>numbers = [1, 2, 3, 4, 5]<br><br># Use map to apply a function to all elements of the list<br>squared_numbers = map(lambda x: x**2, numbers)<br><br># Convert map object to a list to print the results<br>squared_numbers_list = list(squared_numbers)<br><br>print(squared_numbers_list)  # Output: [1, 4, 9, 16, 25]</pre><h3>Classes</h3><p><strong>JavaScript</strong></p><pre>class Book <br>{<br>    constructor(title, author, pages) <br>    {<br>        this.title = title;<br>        this.author = author;<br>        this.pages = pages;<br>    }<br>    <br>    describeBook() <br>    {<br>        println(`Book Title: ${this.title}`);<br>        println(`Author: ${this.author}`);<br>        println(`Number of Pages: ${this.pages}`);<br>    }<br>}</pre><p><strong>Python</strong></p><pre>class Book:<br>    def __init__(self, title, author, pages):<br>        self.title = title<br>        self.author = author<br>        self.pages = pages<br>    <br>    def describe_book(self):<br>        print(f&quot;Book Title: {self.title}&quot;)<br>        print(f&quot;Author: {self.author}&quot;)<br>        print(f&quot;Number of Pages: {self.pages}&quot;)</pre><h3>Usage of classes</h3><p><strong>JavaScript</strong></p><pre>// Creating an instance of the Book class<br>// This is actually a real book (see Curriculum section for more info)<br>const myBook = new Book(&quot;Illustrated JavaScript&quot;, &quot;Marian Veteanu&quot;, 684);<br>myBook.describeBook();</pre><p><strong>Python</strong></p><pre># Creating an instance of the Book class<br># This is actually a real book (see Curriculum section for more info)<br>my_book = Book(&quot;Illustrated JavaScript&quot;, &quot;Marian Veteanu&quot;, 684)<br>my_book.describe_book()</pre><h3>Conclusion</h3><p>We encourage you to get involved in refining this comparison. Your contributions, whether they are corrections, enhancements, or new additions, are highly valued. By collaborating, we can create a more accurate and comprehensive guide that benefits all developers interested in learning about JavaScript and Python.</p><h3>Credits</h3><p>This article was influenced by similar comparisons between other programming languages. Please note that clicking on the following links will take you outside <a href="http://codeguppy.com/">codeguppy.com</a> environment.</p><ul><li>Kotlin is like C# <a href="https://ttu.github.io/kotlin-is-like-csharp/">https://ttu.github.io/kotlin-is-like-csharp/</a></li><li>Kotlin is like TypeScript <a href="https://gi-no.github.io/kotlin-is-like-typescript/">https://gi-no.github.io/kotlin-is-like-typescript/</a></li><li>Swift is like Kotlin <a href="https://nilhcem.com/swift-is-like-kotlin/">https://nilhcem.com/swift-is-like-kotlin/</a></li><li>Swift is like Go <a href="http://repo.tiye.me/jiyinyiyong/swift-is-like-go/">http://repo.tiye.me/jiyinyiyong/swift-is-like-go/</a></li><li>Swift is like Scala <a href="https://leverich.github.io/swiftislikescala/">https://leverich.github.io/swiftislikescala/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c8a40d84bac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeguppy/javascript-is-like-python-4c8a40d84bac">JavaScript is like Python</a> was originally published in <a href="https://medium.com/codeguppy">codeguppy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript for Kids]]></title>
            <link>https://medium.com/codeguppy/javascript-for-kids-3192aaae563d?source=rss-124201dddc8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3192aaae563d</guid>
            <dc:creator><![CDATA[Adrian]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 02:42:36 GMT</pubDate>
            <atom:updated>2024-04-04T02:42:36.841Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s make a journey in time and remember those early home computers of late 70s, 80s and 90s that started the entire IT revolution. Perhaps you can still remember the ZX-Spectrum, the Commodore 64 or the BBC Micro. Although very primitive by current standards, those early computers were perfect platforms for learning to code.</p><p>They provided everything a user needed to make the jump into programming: a language (BASIC), a library of friendly commands and a code editor.</p><p>An entire generation of today’s professional developers started their careers by learning to code as kids on those early computers.</p><p>The entry path to coding is no longer as simple at is was back then. Modern computing devices are friendlier and easier to use than ever, but their advanced design makes them very difficult to program them.</p><h3>Introducing CodeGuppy</h3><p>CodeGuppy is trying to address this gap, by recreating the programming experience of those early machines in a new environment adapted to the modern world.</p><p>At a glance, CodeGuppy is an online environment that comes with a modern code editor, a modern language and a set of kid friendly commands. However, instead of BASIC, CodeGuppy is proposing JavaScript as a language of choice.</p><p>What makes JavaScript especially interesting for education is its flexible syntax which makes the language appealing to beginners. When further coupled with a library of graphic oriented functions, JavaScript becomes the perfect language for introducing kids as kids as young as 10 into the wonderful world of programming!</p><p>Either if the kids are transitioning from a block-based language such as Scratch, or they are taking the contact for the very first time with the world of programming, we’re sure they’ll have a fun and engaging experience in CodeGuppy.</p><h3>Let’s understand what makes CodeGuppy unique</h3><p>At the very base of CodeGuppy sits the p5.js library — a library with deep roots into academia. The library provides all the basic graphical commands that young students will use in their programs. Due to this design aspect, nearly 99% of p5.js sketches can be adapted to run on CodeGuppy. In the same time, the same design aspect allows CodeGuppy students to graduate to the more complex creative programming area once they are ready.</p><p>Since CodeGuppy was designed from the ground up as an educational environment, it builds on top of p5.js a series of new tools and APIs that makes the entry to programming more appealing to younger students.</p><h4>Built-in coding environment</h4><p>CodeGuppy provides a modern coding environment designed especially for kids and teens. The coding environment provides all the tools necessary to learn coding as well as develop own programs.</p><p>As an online environment there is nothing to install, the environment running directly in the browser. Any Windows, Mac or Chromebook computer being perfect for CodeGuppy. As a matter of fact, CodeGuppy runs also on tablets but we strongly advice to use a computer with a physical keyboard. At the end of the day coding involves a lot of typing.</p><p>The main components of the coding environment are the coding area, where the program is entered, and the graphical output area where the results are displayed. The system initializes automatically the graphical output using a predefined 800x600 canvas that is big enough for a wide range of programs.</p><p>There are also various pallets that can be used to explore included assets and commands.</p><h4>Built-in assets</h4><p>To make programming fun and engaging, CodeGuppy comes with built-in assets such as nice backgrounds, animated sprites as well as music and sound effects.</p><p>All these assets can be accessed and manipulated from code by using simple and intuitive commands: Example: background(&quot;image_name&quot;); to set the background image or music(&quot;tune_name&quot;); to play a certain tune as a background music.</p><p>Some beginners find a possible entry path into coding via drag-and-dropping the assets into the code area and noticing the generated code. For example, the following program was created only by drag and dropping assets:</p><pre>background(&#39;Road&#39;);<br>sprite(&#39;plane&#39;);<br>music(&#39;Rainbow&#39;);</pre><p>Try to type it in to see what it does. Remember that JavaScript is case sensitive, so type carefully.</p><h4>Type-In programs</h4><p>With CodeGuppy, type-in programs are back! Popular in the 70s and 80s, type-in programs were small programs included in magazines or other printed materials that required users to enter them from the keyboard.</p><p>Although this method of entering programs is not very time efficient, it is very good in educational terms. Users that type in programs gets comfortable much quicker with the language and eventually learn to program much faster.</p><p>Afterall, coding is all about typing programs using the keyboard.</p><p>How CodeGuppy enables type-in programs? Very simple: since all assets and libraries come included, young coders need to focus only on the coding part without having to deal with complex project organization or library management like in other environments.</p><p>In coding clubs and class settings, educators can take advantage of this feature and provide kids with printed materials containing code listening. Students will just need to type-in the programs and fix the errors as they appear.</p><p>The same feature is also what makes CodeGuppy appealing to book and magazine article authors. Look for a magazine near you for a CodeGuppy program ready to be typed-in!</p><h4>Gently introduction to programming</h4><p>A certain consideration has been put into CodeGuppy design to facilitate a gentle introduction to programming for beginners.</p><p>In CodeGuppy, even a simple command such as circle(400, 300, 300); becomes a valid program. There is no need to define any setup() or draw() function as in regular p5.js sketches.</p><p>Functions are advanced concepts and having to deal with them at the first steps into programming would make the whole teaching moment more difficult. Of course, functions are supported but they can be introduced later in the curriculum after the basic concepts are understood.</p><p>Did you notice the above-mentioned circle command? This is also one example in which CodeGuppy platform caters to the attention of young coders. The circle command is just an example of a simplified API that CodeGuppy adds on top of p5.js</p><p>As a matter of fact, circle is one of the very first commands that is introduced by CodeGuppy in the coding lessons. You’d be amazed how much fun young kids have with the circle command. An entire bear can be drawn just using circles. Give a try to the following program if you don’t believe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AX2AGGGH4iN3Ktjh.png" /></figure><h4>Graphics and game building API</h4><p>CodeGuppy is using graphics and game programming to capture the attention and light the imagination of young coders. Since all kids can related to video games is natural for them to dream to build one of their own. Besides the regular p5.js graphics APIs, CodeGuppy further enriches this area with additional new capabilities such as:</p><ul><li>Support for manipulating sprites</li><li>Support for creating multi-scene games</li></ul><h4>Included tutorials and examples</h4><p>The first experience that one has when visits the <a href="http://codeguppy.com/">codeguppy.com</a> website is the multitude of tutorials and code examples.</p><p>Although currently in beta, CodeGuppy still contains a serious number of programs that can be used as a starting point in creating of new programs.</p><p>The included examples span different categories from basic games and pixel art applications to math and advanced polar coordinates programs.</p><h4>Browse / Adapt / Share</h4><p>On CodeGuppy students are encouraged to remix existing programs and reshare modifications. All included programs as well as programs received from friends can be remixed with a single button click.</p><p>The sharing aspect brings also a positive reinforcement aspect to the whole coding experience. By receiving friends and family feedback, young coders are feeling more motivated to continue coding and create new programs.</p><p>Advanced users can even embed or link their created CodeGuppy programs in their blogs or social media channels.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3192aaae563d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeguppy/javascript-for-kids-3192aaae563d">JavaScript for Kids</a> was originally published in <a href="https://medium.com/codeguppy">codeguppy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recursion in JavaScript — Practical examples]]></title>
            <link>https://medium.com/codeguppy/recursion-in-javascript-practical-examples-fa37dd18261b?source=rss-124201dddc8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa37dd18261b</guid>
            <dc:creator><![CDATA[Adrian]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 02:33:44 GMT</pubDate>
            <atom:updated>2024-04-04T02:33:44.091Z</atom:updated>
            <content:encoded><![CDATA[<h3>Recursion in JavaScript — Practical examples</h3><p>Recursion is one of the most useful but very little understood programming technique. There are special kind of problems that can be solved very easy and elegant with a recursive function (e.g. locating a file in an hierarchical file system).</p><p>This article doesn’t intend to offer an explanation of how recursion works … but insted in presents you <strong>eight</strong> classical problems implemented both using a recursive solution as well as an iterative solution.</p><p>As you can probably see … for some problems recursion comes more naturally, as for the others it should not be the first choise.</p><h3>How to run the code?</h3><p>Examples from this article have been developed using the <a href="https://codeguppy.com/code.html">codeguppy.com editor</a>. However just by replacing println() with console.log() you can run it in any environment you prefer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*uPYSYUpbYWXZOp-s.png" /></figure><p>Without further ado, let’s see the problems and their solutions.</p><h3>1. Calculate the sum of natural number up to n</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*cnRxW2c3LWhs-R2q.png" /></figure><h4>Recursive solution</h4><pre>let sum = addTo(10);<br>println(sum);</pre><pre>function addTo(n)<br>{<br>    if (n == 0)<br>        return 0;<br>    <br>    return n + addTo(n - 1);<br>}</pre><h4>Iterative solution</h4><pre>let sum = addTo(10);<br>println(sum);</pre><pre>function addTo(n)<br>{<br>    let sum = 0;<br>    <br>    for(let i = 1; i &lt;= n; i++)<br>    {<br>        sum += i;<br>    }<br>    <br>    return sum;<br>}</pre><h3>2. Calculate factorial of n. Reminder n! = 1 * 2 * … * n</h3><h4>Recursive solution</h4><pre>let prod = factorial(10);<br>println(prod);</pre><pre>function factorial(n)<br>{<br>    if (n &lt;= 1)<br>        return 1;<br>        <br>    return n * factorial(n - 1);<br>}</pre><h4>Iterative solution</h4><pre>let prod = factorial(10);<br>println(prod);</pre><pre>function factorial(n)<br>{<br>    let prod = 1;<br>    <br>    for(let i = 1; i &lt;= n; i++)<br>    {<br>        prod *= i;<br>    }<br>    <br>    return prod;<br>}</pre><h3>3. Calculate the value of n to the m power</h3><h4>Recursive solution</h4><pre>println(powerNo(3, 2));</pre><pre>function powerNo(n, m)<br>{<br>    if (m == 0)<br>        return 1;<br>    <br>    if (m == 1)<br>        return n;<br>        <br>    return n * powerNo(n, m - 1);<br>}</pre><h4>Iterative solution</h4><pre>println(powerNo(3, 2));</pre><pre>function powerNo(n, m)<br>{<br>    let prod = 1;<br>    <br>    for(let i = 1; i &lt;= m; i++)<br>    {<br>        prod *= n;<br>    }<br>    <br>    return prod;<br>}</pre><h3>4. Find the nth Fibonacci number</h3><h4>Recursive solution</h4><pre>function findFibonacci(n)<br>{<br>    if (n == 0)<br>        return 0;<br>        <br>    if (n == 1)<br>        return 1;<br>        <br>    return findFibonacci(n - 1) + findFibonacci(n - 2);<br>}</pre><pre>let n = findFibonacci(10);<br>println(n);</pre><h4>Iterative solution</h4><pre>function findFibonacci(n)<br>{<br>    let fib0 = 0;<br>    let fib1 = 1;</pre><pre>    if (n == 0)<br>        return fib0;<br>        <br>    if (n == 1)<br>        return fib1;</pre><pre>    let fib;<br>    <br>    for(let i = 2; i &lt;= n; i++)<br>    {<br>        fib = fib0 + fib1;<br>        <br>        fib0 = fib1;<br>        fib1 = fib;<br>    }<br>    <br>    return fib;<br>}</pre><pre>println(findFibonacci(10));</pre><h3>5. Calculate the sum of elements of an array of numbers</h3><h4>Recursive solution</h4><pre>let ar = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];<br>let n = sum(ar);<br>println(n);<br></pre><pre>function sum(ar)<br>{<br>    return _sum(ar, ar.length - 1);<br>}</pre><pre>function _sum(ar, index)<br>{<br>    if (index == 0)<br>        return ar[0];<br>        <br>    return ar[index] + _sum(ar, index - 1);<br>}</pre><h4>Iterative solution</h4><pre>let ar = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];<br>let n = sum(ar);<br>println(n);</pre><pre>function sum(ar)<br>{<br>    let sum = 0;<br>    <br>    for(let el of ar)<br>    {<br>        sum += el;<br>    }<br>    <br>    return sum;<br>}</pre><h3>6. Sort an array of numbers using bubble sort algorithm</h3><h4>Recursive solution</h4><pre>let ar = [23, 1000, 1, -1, 8, 3];<br>println(ar);<br>bubbleSort(ar);<br>println(ar);</pre><pre>function bubbleSort(ar)<br>{<br>    let shouldSort = false;</pre><pre>    for(let i = 0; i &lt; ar.length - 1; i++)<br>    {<br>        let a = ar[i];<br>        if ( a &gt; ar[i+1] )<br>        {<br>            ar[i] = ar[i+1];<br>            ar[i+1] = a;<br>            shouldSort = true;<br>        }<br>    }<br>    <br>    if (shouldSort)<br>    {<br>        bubbleSort(ar);<br>    }<br>}</pre><h4>Iterative solution</h4><pre>let ar = [23, 1000, 1, -1, 8, 3];<br>println(ar);<br>bubbleSort(ar);<br>println(ar);</pre><pre>function bubbleSort(ar)<br>{<br>    let shouldSort = true;</pre><pre>    while(shouldSort)<br>    {<br>        shouldSort = false;<br>        <br>        for(let i = 0; i &lt; ar.length - 1; i++)<br>        {<br>            let a = ar[i];<br>            if ( a &gt; ar[i+1] )<br>            {<br>                ar[i] = ar[i+1];<br>                ar[i+1] = a;<br>                shouldSort = true;<br>            }<br>        }<br>    }<br>}</pre><h3>7. Find a number in a sorted array (binary search)</h3><h4>Recursive solution</h4><pre>//        0   1   2   3   4   5   6   7   8   9<br>let ar = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];</pre><pre>let position = findNumber(90, ar);<br>println(position);</pre><pre>// Find number n in sorted array ar<br>// Returns array index if found or -1 if not found<br>function findNumber(n, ar)<br>{<br>    return _findNumber(n, ar, 0, ar.length - 1);<br>}</pre><pre>// Find number n in sorted array ar in between indexes i1 and i2<br>// using recursive approach<br>function _findNumber(n, ar, i1, i2)<br>{<br>    if (i2 &lt; i1)<br>        return -1;</pre><pre>    println(&quot;Checking interval: [&quot; + i1 + &quot;, &quot; + i2 + &quot;]&quot;);<br>    <br>    let mid = i1 + Math.floor((i2 - i1) / 2);<br>    <br>    if (n === ar[mid])<br>        return mid;<br>        <br>    if (n &lt; ar[mid])<br>        return _findNumber(n, ar, i1, mid - 1);<br>        <br>    return _findNumber(n, ar, mid + 1, i2);<br>}</pre><h4>Iterative solution</h4><pre>//        0   1   2   3   4   5   6   7   8   9<br>let ar = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];</pre><pre>let position = findNumber(90, ar);<br>println(position);</pre><pre>// Find number n in sorted array ar using iterative approach<br>// Returns array index if found or -1 if not found<br>function findNumber(n, ar)<br>{<br>    let i1 = 0;<br>    let i2 = ar.length - 1;<br>    <br>    while(i1 &lt;= i2)<br>    {<br>        println(&quot;Checking interval: [&quot; + i1 + &quot;, &quot; + i2 + &quot;]&quot;);<br>        <br>        let mid = i1 + Math.floor((i2 - i1) / 2);<br>        <br>        if (n === ar[mid])<br>            return mid;</pre><pre>        if (n &lt; ar[mid])<br>        {<br>            i2 = mid - 1;<br>        }<br>        else<br>        {<br>            i1 = mid + 1;<br>        }<br>    }<br>    <br>    return -1;<br>}</pre><h3>8. Find the maximum number in an array containing numbers or other arrays of numbers</h3><h4>Recursive solution</h4><pre>let ar = [2, 4, 10, [12, 4, [100, 99], 4], [3, 2, 99], 0];</pre><pre>let max = findMax(ar);<br>println(&quot;Max  = &quot;, max);</pre><pre>// Use recursion to find the maximum numeric value in an array of arrays<br>function findMax(ar)<br>{<br>    let max = -Infinity;</pre><pre>    // Cycle through all the elements of the array<br>    for(let i = 0; i &lt; ar.length; i++)<br>    {<br>        let el = ar[i];</pre><pre>        // If an element is of type array then invoke the same function<br>        // to find out the maximum element of that subarray<br>        if ( Array.isArray(el) )<br>        {<br>            el = findMax( el );<br>        }</pre><pre>        if ( el &gt; max )<br>        {<br>            max = el;<br>        }<br>    }</pre><pre>    return max;<br>}</pre><h4>Iterative solution</h4><pre>// Find the maximum number in a jagged array of numbers or array of numbers<br>// Do not use recursion</pre><pre>let ar = [2, 4, 10, [12, 4, [100, 99], 4], [3, 2, 99], 0];</pre><pre>let max = findMax(ar);<br>println(&quot;Max  = &quot;, max);</pre><pre>// Use a stack to find the maximum numeric value in an array of arrays<br>function findMax(arElements)<br>{<br>    let max = -Infinity;</pre><pre>    // This is the stack on which will put the first array and then <br>    // all the other sub-arrays that we find as we traverse an array     <br>    let arrays = [];</pre><pre>    arrays.push(arElements);</pre><pre>    // Loop as long as are arrays added to the stack for processing<br>    while(arrays.length &gt; 0)<br>    {<br>        // Extract an array from the stack<br>        ar = arrays.pop();<br>        <br>        // ... and loop through its elements<br>        for(let i = 0; i &lt; ar.length; i++)<br>        {<br>            let el = ar[i];</pre><pre>            // If an element is of type array, we&#39;ll add it to stack<br>            // to be processed later<br>            if ( Array.isArray(el) )<br>            {<br>                arrays.push(el);<br>                continue;<br>            }<br>            <br>            if ( el &gt; max )<br>            {<br>                max = el;<br>            }<br>        }<br>    }</pre><pre>    return max;<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa37dd18261b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeguppy/recursion-in-javascript-practical-examples-fa37dd18261b">Recursion in JavaScript — Practical examples</a> was originally published in <a href="https://medium.com/codeguppy">codeguppy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Are There 8 Bits in a Byte?]]></title>
            <link>https://medium.com/codeguppy/why-are-there-8-bits-in-a-byte-cf07dc66c342?source=rss-124201dddc8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf07dc66c342</guid>
            <dc:creator><![CDATA[Adrian]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 02:24:15 GMT</pubDate>
            <atom:updated>2024-04-04T02:24:15.091Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello young explorers! Today, we’re diving into a digital mystery: Why are there 8 <strong>bits</strong> in a <strong>byte</strong>? This might sound like a simple question, but it takes us on an adventure through the history of computers and how they think!</p><h3>What’s a Bit? What’s a Byte?</h3><p>First, let’s talk about what bits and bytes are. A bit is the smallest unit of data in computing. It’s like a tiny light switch that can be either off (0) or on (1).</p><p>A byte, on the other hand, is a group of bits that work together to represent something more significant, like a letter on your keyboard or a color in a picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7yhxQm_ElYan4Y4E.png" /></figure><h3>The Journey to 8 Bits</h3><p>Long ago, in the early days of computing, there wasn’t a standard size for these groups of bits. Different computers used different sizes, like 5, 6, 7, or even up to 12 bits per group!</p><p>So, why did 8 bits win the race? There are a few reasons:</p><p><strong>Just Right for Characters</strong>: The English alphabet, numbers, and special characters like !, @, #, etc., can all be represented using different combinations of 8 bits. This size is perfect for creating a system (known as ASCII) that can represent up to 256 different characters or instructions, which was more than enough for English and basic symbols.</p><p><strong>Efficiency</strong>: 8 bits create a balance between not having enough options (which would limit what computers can do) and having too many options (which would make computers more complex and expensive). It’s the “just right” size for a wide range of tasks.</p><p><strong>Power of 2</strong>: Computer scientists love numbers that are powers of 2 (like 2, 4, 8, 16…), because computers think in binary (the language of 0s and 1s). It makes calculations and data storage more efficient and simpler to design.</p><p><strong>Technology Advances</strong>: As technology evolved, the benefits of using 8 bits became even clearer. It made it easier for different types of computers to talk to each other and share information, helping to create the connected world we live in today.</p><h3>The Legacy Continues</h3><p>The decision to standardize on 8 bits wasn’t made overnight. It was the result of trial, error, and a lot of smart thinking by the early computer scientists. And once it was set, it paved the way for the explosion of digital technology we rely on every day, from smartphones to the internet.</p><h3>Beyond the Byte</h3><p>While the byte (8 bits) is still fundamental, the digital world has grown. Now, we talk about kilobytes, megabytes, gigabytes, and even terabytes to measure the vast amounts of data we use and create every day. But at the heart of it all, those 8-bit bytes are working tirelessly, helping us to write stories, share pictures, play games, and explore the vastness of the internet.</p><h3>Conclusion</h3><p>So, why are there 8 bits in a byte? It’s a combination of practicality, efficiency, and a bit of historical happenstance. This choice helped shape the digital age, making technology accessible and useful for everyone. And who knows? Maybe one day, you’ll be part of the next big decision in computing history!</p><p>Remember, every byte counts in the vast universe of computing, and now you know the story behind those 8-bit heroes that make up the digital world. Keep exploring, keep questioning, and who knows what mysteries you’ll uncover next!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf07dc66c342" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeguppy/why-are-there-8-bits-in-a-byte-cf07dc66c342">Why Are There 8 Bits in a Byte?</a> was originally published in <a href="https://medium.com/codeguppy">codeguppy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Kids Learned Programming in the 80s?]]></title>
            <link>https://medium.com/codeguppy/how-kids-learned-programming-in-the-80s-835005758b88?source=rss-124201dddc8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/835005758b88</guid>
            <dc:creator><![CDATA[Adrian]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 02:23:30 GMT</pubDate>
            <atom:updated>2024-04-04T02:23:30.006Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there, young coders! Ever wondered how kids like you learned to program computers back in the 1980s, long before smartphones, tablets, and super-fast laptops? Well, buckle up, because we’re time-traveling to the era of big hair, cassette tapes, and the dawn of home computing.</p><p>Let’s explore the fascinating world of the <strong>ZX-Spectrum 48K</strong> and <strong>Commodore 64</strong> computers and dive into the <strong>BASIC</strong> programming language — the tools that sparked many of today’s tech geniuses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*UIEkwcnV4zl31yMUQWe0Tg.jpeg" /></figure><h3>The ZX-Spectrum 48K: A Rainbow of Possibilities</h3><p>Imagine a tiny, rainbow-striped computer that could connect to your TV and introduce you to the wonders of programming. That’s the <strong>ZX-Spectrum 48K</strong> for you! Launched in the UK by Sinclair Research in 1982, this little marvel was many kids’ first encounter with computing. It was affordable, which made it a hit with families. The Spectrum came with a built-in programming language called <strong>BASIC</strong>, allowing anyone to start coding right out of the box. Kids could create their own games, animations, and programs, learning the basics of programming in a fun, hands-on way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TzHWAS7g6Cw3rYfz.jpg" /></figure><h3>Commodore 64: The Cool Kid on the Block</h3><p>Across the ocean, another star was born: the <strong>Commodore 64</strong>, affectionately known as the <strong>C64</strong>. With its iconic beige case and rainbow logo, the C64 became the best-selling single computer model of all time. It boasted impressive graphics and sound for its era, making it perfect for games. But it wasn’t just about playing games; the C64 also came equipped with the <strong>BASIC</strong> programming language, encouraging kids to become creators. Many future programmers cut their teeth on the C64, typing in lines of code to bring their own digital worlds to life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RKk3Gmo33dF9cpRK.jpg" /></figure><h3>BASIC: Let’s learn how to code</h3><p>BASIC, which stands for Beginner’s All-purpose Symbolic Instruction Code, was the first programming language for many budding programmers in the 80s. It was designed to be easy to learn, with simple commands that made sense to beginners. Both the ZX-Spectrum and the Commodore 64 used versions of BASIC as their programming language, making them powerful tools for education. Kids could start with simple commands and gradually build up to more complex programs, learning logical thinking and problem-solving skills along the way.</p><p>Back in the 80s, learning to program often meant typing in long programs from magazines or books. Mistakes were common, and debugging was part of the fun. This hands-on approach taught patience, attention to detail, and the thrill of seeing your code come to life. It wasn’t always easy, but the sense of accomplishment when your program finally ran as intended was unbeatable.</p><h3>JavaScript is like BASIC</h3><p>Fast forward from the 80s, and we land in a world where programming languages have evolved dramatically. Yet, the mission to make coding accessible and fun for beginners continues. Enter JavaScript, a language that, in many ways, is the modern equivalent of BASIC for today’s young coders. Just as BASIC opened the doors to programming for kids in the 80s, JavaScript is doing the same today, especially through platforms like CodeGuppy.</p><p><a href="http://codeguppy.com/">codeguppy.com</a> is a shining example of how JavaScript has been made as easy to use as BASIC once was. Designed with young learners in mind, CodeGuppy takes a leaf from the BASIC book, offering an intuitive, engaging platform where kids can learn to code by creating games, animations, and more. It’s a playground where JavaScript comes to life, allowing users to see the immediate results of their code, much like the immediate feedback loop that made BASIC so beloved.</p><p><a href="http://codeguppy.com/">codeguppy.com</a> provides a plethora of resources, tutorials, and projects tailored for beginners. This nurturing environment is perfect for young coders to experiment, learn, and grow their coding skills in a fun, supportive way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h4evnwKQmDW_pwHJ.png" /></figure><h3>Conclusion</h3><p>While technology has advanced light-years since the 80s, the basic principles of programming have remained the same. The spirit of exploration, creativity, and problem-solving that kids experienced with the ZX-Spectrum and Commodore 64 continues to inspire young programmers today. Whether you’re coding on <a href="http://codeguppy.com/">codeguppy.com</a> or on any other modern coding environment, you’re part of a long tradition of digital pioneers. So, next time you sit down to program, remember you’re following in the footsteps of those 80s kids, exploring the limitless potential of what you can build with code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=835005758b88" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeguppy/how-kids-learned-programming-in-the-80s-835005758b88">How Kids Learned Programming in the 80s?</a> was originally published in <a href="https://medium.com/codeguppy">codeguppy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Raspberry Pi Paper Computer in Your Coding Club]]></title>
            <link>https://medium.com/codeguppy/building-a-raspberry-pi-paper-computer-in-your-coding-club-e30a63788bd2?source=rss-124201dddc8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e30a63788bd2</guid>
            <dc:creator><![CDATA[Adrian]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 02:21:32 GMT</pubDate>
            <atom:updated>2024-04-04T02:21:32.095Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Are you looking for a fun and educational project to engage your coding club members? Building a “Raspberry Pi Paper” computer is an exciting endeavor that combines coding, electronics, and crafting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7LWtMgmBucD59OPm.jpg" /></figure><p>In this article, we’ll guide you through the process of creating a simple yet functional Raspberry Pi-powered paper computer that can be a fantastic hands-on learning experience for middle and high school students.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Es1nORX1u0RCgHuP.jpg" /></figure><h3>Materials Needed</h3><p>Before you start, gather the following materials:</p><ol><li>Raspberry Pi 400</li><li>MicroSD card (8GB or larger)</li><li>LCD screen</li><li>HDMI cable</li><li>USB PowerBank (to make it portable)</li><li>Power supply USB cable</li><li>A piece of flexible cardboard</li><li>Assorted craft supplies (markers, colored paper, glue, scissors, etc.)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yn7DlP7110b5rNXU.jpg" /></figure><p>Let’s do first a quick test with the case. Connect the LCD panel to the Raspberry Pi 400 computer using the HDMI cable and then power on the entire assembly.</p><p>If everthing works, you can start designing a case around these components using thing cardboard.</p><h3>Designing the Paper Computer</h3><ol><li>Measure and cut the cardboard into a size that fits the Raspberry Pi and screen comfortably.</li><li>Design the layout of your paper computer. You can use markers, colored paper, and other craft supplies to make it visually appealing.</li><li>Cut holes in the board to accommodate the Raspberry Pi 400 keyboard and screen.</li><li>Attach the Raspberry Pi 400 and screen securely to the board using glue or double-sided tape.</li><li>Connect the screen to the Raspberry Pi 400 using the HTMI cable</li><li>Connect the USB power bank using the USB cable</li><li>Decorate your paper computer with creative elements like labels, and graphics.</li><li>Ensure that all the components are neatly arranged and the cables are organized.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o_IOi8rNp0lBWlpN.jpg" /></figure><p>This is the back of the computer. You can use shorter cables for a more esthetic look.</p><h3>Use a code editor</h3><ol><li>Open <a href="http://codeguppy.com/">codeguppy.com</a> in a browser on the new Raspberry Pi paper computer</li><li>Code a small program</li><li>Currently the UI of <a href="http://codeguppy.com/">codeguppy.com</a> is not optimized for small and ultrawide screens but also this computer is not for real coding.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_T22ez54GQlEysy4.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y0FU3Yv_qqqoyL_B.jpg" /></figure><h3>Conclusion</h3><p>Building a “Raspberry Pi Paper” computer in your coding club is a fantastic way to introduce students to coding, electronics, and creative design. So, grab your Raspberry Pi 400 and the other supplies, and start building your own paper computer today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e30a63788bd2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeguppy/building-a-raspberry-pi-paper-computer-in-your-coding-club-e30a63788bd2">Building a Raspberry Pi Paper Computer in Your Coding Club</a> was originally published in <a href="https://medium.com/codeguppy">codeguppy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Coding Projects for Middle and High School Students]]></title>
            <link>https://medium.com/codeguppy/10-coding-projects-for-middle-and-high-school-students-f910f8417455?source=rss-124201dddc8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f910f8417455</guid>
            <dc:creator><![CDATA[Adrian]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 02:17:38 GMT</pubDate>
            <atom:updated>2024-04-04T02:17:38.113Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you a middle or high school teacher looking for exciting and educational coding projects to engage your students? Or perhaps you’re a student eager to explore the fascinating world of programming? Look no further!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*PQdMrLcLA6yfJuhyaa1OYA.jpeg" /></figure><p>We’ve compiled a list of captivating project ideas that are perfect for students at these grade levels. And the best part? These projects are all available on CodeGuppy, a fantastic platform for learning and experimenting with coding.</p><h3>1. Draw with Code</h3><p>Encourage artistic expression through coding. Students can create unique drawings and artwork using code as their canvas. This project combines coding and artistry in a captivating way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gsd15Oa-PhaX4A1_.png" /></figure><p><a href="https://codeguppy.com/code.html?t=draw">CodeGuppy Draw with Code Tutorial</a></p><h3>2. Greeting Cards with Code</h3><p>Coding virtual greeting cards is an excellent way to learn how to code. Codeguppy is offering tons of greeting card projects that you can use as starting point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*uHP4VkuzUEadahN-.png" /></figure><p><a href="https://codeguppy.com/code.html?t=Happy_Holidays">Greeting cards</a></p><h3>3. Turtle Graphics</h3><p>Turtle Graphics is a fantastic way to introduce students to the world of coding. They can create beautiful drawings and patterns by giving commands to a virtual turtle. This project enhances problem-solving skills and creativity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vNX7OxCcqWHz-YF0.png" /></figure><p><a href="https://codeguppy.com/code.html?t=turtle_graphics">CodeGuppy Turtle Graphics Tutorial</a></p><h3>4. Breakout Game</h3><p>Breakout is a classic arcade game where students can design their own version. They’ll learn about game development concepts like collision detection and game loops while having fun playing their own creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EO7lS3QTQ22tnb45.png" /></figure><p><a href="https://codeguppy.com/code.html?t=breakout">CodeGuppy Breakout Tutorial</a></p><h3>5. Invaders Game</h3><p>Challenge students to recreate the iconic Space Invaders game. They’ll gain valuable insights into game design, user input handling, and more. It’s a great way to foster creativity and critical thinking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yjE237lzV4qgd4CS.png" /></figure><p><a href="https://codeguppy.com/code.html?t=breakout">CodeGuppy Invaders Tutorial</a></p><h3>6. Analog Clock</h3><p>Students can build a digital analog clock, perfect for learning about graphics and animations. This project introduces concepts like angles and trigonometry while creating a functional clock.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7IMgkqi0DdDVcTRi.png" /></figure><p><a href="https://codeguppy.com/code.html?t=clock">CodeGuppy Analog Clock Tutorial</a></p><h3>7. Plot a Function</h3><p>Introduce students to mathematics and coding simultaneously. They can create a program to plot various mathematical functions, helping them understand the relationship between code and real-world concepts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qzlIRUu0TAPXJHWh.png" /></figure><p><a href="https://codeguppy.com/code.html?t=fngraph">CodeGuppy Plot a Function Tutorial</a></p><h3>8. Prime Numbers and Fibonacci</h3><p>Explore the world of mathematical algorithms with projects like finding prime numbers, generating Fibonacci sequences, or even working with cards. These projects offer a deeper understanding of numerical concepts and problem-solving.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BjPhCuuNInOTOQjz.png" /></figure><p><a href="https://codeguppy.com/code.html?t=primes">CodeGuppy Prime Numbers Tutorial</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ei8uHB9PbpexqPvf.png" /></figure><p><a href="https://codeguppy.com/code.html?t=fibonacci">CodeGuppy Fibonacci Tutorial</a></p><h3>9. Artist and Color Blokly</h3><p>Challenge students to become digital artists. They can create stunning digital artwork or experiment with color patterns using code. These projects encourage creativity and artistic exploration.</p><p><a href="https://codeguppy.com/code.html?t=artist">CodeGuppy Artist Tutorial</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IPmPwfoZwQwFcajK.png" /></figure><p><a href="https://codeguppy.com/code.html?t=blocky">CodeGuppy Color Blokly Tutorial</a></p><h3>10. Mars Attack</h3><p>Take coding to a new level by developing a space-themed game like “Mars Attack.” Students can design their own intergalactic adventure, gaining insight into game mechanics and programming logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UKPipE0heiyay9mJ.png" /></figure><p><a href="https://codeguppy.com/code.html?t=mars_attack">CodeGuppy Mars Attack Tutorial</a></p><h3>Get Started with CodeGuppy Today!</h3><p>With the resources and tutorials available on CodeGuppy, students can begin coding these captivating projects right away.</p><p>Visit CodeGuppy today, explore the tutorials, and begin coding these captivating projects. With CodeGuppy, students can unlock their creativity and develop valuable coding skills.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f910f8417455" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeguppy/10-coding-projects-for-middle-and-high-school-students-f910f8417455">10 Coding Projects for Middle and High School Students</a> was originally published in <a href="https://medium.com/codeguppy">codeguppy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[8 Computer Science Algorithms You Can Implement in JavaScript]]></title>
            <link>https://medium.com/codeguppy/8-computer-science-algorithms-you-can-implement-in-javascript-47aaf9b3bf67?source=rss-124201dddc8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/47aaf9b3bf67</guid>
            <dc:creator><![CDATA[Adrian]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 02:15:53 GMT</pubDate>
            <atom:updated>2024-04-04T02:15:53.882Z</atom:updated>
            <content:encoded><![CDATA[<p>In the realm of computer science, algorithms play an important role in solving complex problems, optimizing processes, and enhancing the efficiency of computational tasks.</p><p>JavaScript, with its versatility and wide adoption, provides a fantastic platform for exploring and implementing these algorithms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*UclgiBR7u-qSe1MFflnrRQ.jpeg" /></figure><p>Whether you’re a student, a hobbyist, or a professional developer, understanding and coding these algorithms can sharpen your problem-solving skills and deepen your comprehension of computer science concepts. Here are eight engaging algorithms that we implemented in JavaScript. Feel free to fork the projects and explore the code.</p><h3>1. Flood Fill</h3><p>The Flood Fill algorithm is used to determine the area connected to a given node in a multi-dimensional array. It’s commonly used in paint programs for filling bounded areas with color and in game development for map analysis.</p><p>The algorithm works by recursively filling adjacent cells of a selected cell until it hits a boundary. Implementing Flood Fill in JavaScript is a great way to understand recursion and its applications in graphical operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u8mPurE_y2VtNnVh.png" /></figure><p><a href="https://codeguppy.com/code.html?t=flood_fill">CodeGuppy Flood Fill Tutorial</a></p><h3>2. Bresenham’s Line Algorithm</h3><p>Bresenham’s Line Algorithm is a simple, efficient way to draw straight lines on a pixelated grid, such as a computer screen. Unlike other line-drawing algorithms that may require floating-point arithmetic, Bresenham’s algorithm uses incremental error accumulation to decide the next pixel to draw, ensuring smooth lines with integer calculations. It’s an excellent exercise in understanding how computer graphics work at a fundamental level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BjevWIEhUXk0wXPm.png" /></figure><p><a href="https://codeguppy.com/code.html?t=bresenham">CodeGuppy Bresenham Tutorial</a></p><h3>3. Knight’s Tour</h3><p>The Knight’s Tour is a classic chess problem. The goal is to move a knight on a chessboard in such a way that it visits every square exactly once. This problem can be approached as a graph traversal challenge, making it a perfect candidate for exploring backtracking algorithms in JavaScript. Implementing the Knight’s Tour can help you grasp the concepts of backtracking and depth-first search.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BmVDu-neBmOdGMtO.png" /></figure><p><a href="https://codeguppy.com/code.html?t=knights_tour">CodeGuppy Knight’s Tour Tutorial</a></p><h3>4. Eight Queens</h3><p>The Eight Queens puzzle asks how to place eight queens on an 8x8 chessboard so that no two queens threaten each other. This means placing the queens such that no two queens share the same row, column, or diagonal. Like the Knight’s Tour, solving the Eight Queens puzzle in JavaScript is an excellent way to practice backtracking algorithms, offering insights into constraint satisfaction problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XJJqw6DqO-Yjpx2W.png" /></figure><p><a href="https://codeguppy.com/code.html?t=eight_queens">CodeGuppy Eight Queens Tutorial</a></p><h3>5. Sudoku Solver</h3><p>Sudoku is a popular puzzle that involves filling a 9x9 grid with digits so that each column, each row, and each of the nine 3x3 subgrids contain all the digits from 1 to 9. Writing a Sudoku solver in JavaScript challenges you to apply backtracking algorithms to a real-world problem, enhancing your understanding of how these algorithms can be adapted to various contexts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9Or1fwvW5lGKvE7L.png" /></figure><p><a href="https://codeguppy.com/code.html?t=sudoku">CodeGuppy Sudoku Tutorial</a></p><h3>6. Run-Length Encoding (RLE) Compression</h3><p>RLE is a simple form of data compression in which sequences of the same data value are stored as a single data value and count. Implementing RLE in JavaScript is straightforward and provides a practical introduction to the concepts of data compression, string manipulation, and the trade-offs between space and time complexity in algorithm design.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9CQaWK10EUu78eix.png" /></figure><ul><li><a href="https://codeguppy.com/code.html?t=ascii_rle">ASCII RLE Compression</a></li><li><a href="https://codeguppy.com/code.html?t=binary_rle">Binary RLE Compression</a></li></ul><h3>7. Bubble Sort</h3><p>Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. While not the most efficient sorting method for large datasets, visualizing Bubble Sort in JavaScript, with an animation, offers a clear way to understand the basics of sorting algorithms, loops, and array manipulation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c3EuEA268FHn_ikt.png" /></figure><p><a href="https://codeguppy.com/code.html?t=visual_sort">CodeGuppy Visualizing Bubble Sort Tutorial</a></p><h3>8. Perceptron</h3><p>The Perceptron is a fundamental building block of neural networks, representing the simplest form of a feedforward neural network. Implementing a Perceptron in JavaScript allows you to dip your toes into the fascinating world of machine learning and artificial intelligence, covering concepts such as weights, bias, and learning rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jGUSclc6AYdp2OmP.png" /></figure><p><a href="https://codeguppy.com/code.html?t=perceptron">CodeGuppy Perceptron Tutorial</a></p><h3>Conclusion</h3><p>These eight algorithms represent just a glimpse into the vast world of computer science and its applications.</p><p>By tackling these projects, you not only gain practical coding skills but also deepen your understanding of algorithmic thinking, problem-solving, and computational theory.</p><p>Whether for personal growth, academic purposes, or professional development, implementing these algorithms is a rewarding journey through the heart of computer science.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47aaf9b3bf67" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeguppy/8-computer-science-algorithms-you-can-implement-in-javascript-47aaf9b3bf67">8 Computer Science Algorithms You Can Implement in JavaScript</a> was originally published in <a href="https://medium.com/codeguppy">codeguppy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[7 Educational Tools That You Can Code Yourself in JavaScript]]></title>
            <link>https://medium.com/codeguppy/7-educational-tools-that-you-can-code-yourself-in-javascript-5fffe291408e?source=rss-124201dddc8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fffe291408e</guid>
            <dc:creator><![CDATA[Adrian]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 02:10:23 GMT</pubDate>
            <atom:updated>2024-04-04T02:11:30.844Z</atom:updated>
            <content:encoded><![CDATA[<p>CodeGuppy is a dynamic coding platform tailored for coding education in the classroom or coding clubs. Leveraging the power of the p5.js library — with some thoughtful modifications — CodeGuppy makes coding accessible, fun, and educational.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*Y7AOi6SCLAWq9z8HJvh_8Q.jpeg" /></figure><p>Here, we explore seven educational tools that you can code yourself using JavaScript on the CodeGuppy platform. Each project is offering a unique learning opportunity in mathematics, science, and computer science fundamentals.</p><h3>1. Prime Number Generator</h3><p>Understanding prime numbers is foundational in mathematics and computer science. By coding a prime number generator, students can explore algorithms that identify prime numbers within a specified range. Check out our version below and see the algorithm we use to determine if a number is prime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qqw2XUJp3G9i71KE.png" /></figure><p><a href="https://codeguppy.com/code.html?t=primes">CodeGuppy Prime Number Generator Tutorial</a></p><h3>2. Fibonacci Numbers</h3><p>The Fibonacci sequence, a series where the next number is found by adding up the two numbers before it, is more than just an arithmetic curiosity — it appears in biological settings and is a classic example in recursive programming. Coding a Fibonacci number generator helps students grasp recursion and sequence generation, illuminating the beauty of mathematics in nature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dtW8DQ9pIvDN9y4o.png" /></figure><p><a href="https://codeguppy.com/code.html?t=fibonacci">CodeGuppy Fibonacci Numbers Generator Tutorial</a></p><h3>3. Graph a Math Function</h3><p>Visualizing mathematical functions is important for understanding their behavior. By coding a tool to graph math functions, students can input equations and see their graphical representations. This project not only solidifies an understanding of coordinate geometry but also introduces students to the complexities of computer graphics programming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p9A3BifAcj1xTKR7.png" /></figure><p><a href="https://codeguppy.com/code.html?t=fngraph">CodeGuppy Graph a Math Function Tutorial</a></p><h3>4. Equation Generator</h3><p>An equation generator can be an invaluable tool for students to practice solving various mathematical problems. This tool can randomly generate equations within defined parameters, offering endless practice material.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jL9san6jEf4CCm6I.png" /></figure><p><a href="https://codeguppy.com/code.html?t=eq_gen">CodeGuppy Equation Generator Tutorial</a></p><h3>5. Solar System Simulator</h3><p>A solar system simulator is a captivating project that combines physics, astronomy, and programming. By simulating the motion of planets, students can learn about orbital mechanics, the laws of motion, and how to model these using programming. This project not only teaches scientific concepts but also how to translate theoretical models into visual simulations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ivE16IcaciLsXjJa.png" /></figure><p><a href="https://codeguppy.com/code.html?t=planets">CodeGuppy Planets Tutorial</a></p><h3>6. Unit Converter</h3><p>Building a unit converter teaches students about different measurement systems and the importance of precision in science and daily life. By coding a tool that converts between units like length, weight, and temperature, students practice applying mathematical conversion formulas and learn about user interface design, making their programs user-friendly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OvuAPab00bR45fRy.png" /></figure><p><a href="https://codeguppy.com/code.html?t=converters">CodeGuppy Unit Converts Tutorial</a></p><h3>7. Binary-Decimal-Hexadecimal Converter</h3><p>Understanding different number systems is fundamental in computer science. A binary-decimal-hexadecimal converter tool helps demystify how computers represent and process data. This project strengthens students’ understanding of base systems and offers practical insights into computer architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u1VNbfc3qYyMbxDL.png" /></figure><p><a href="https://codeguppy.com/code.html?t=bin_dec_hex">CodeGuppy Bin-Dec-Hex Tutorial</a></p><h3>Conclusion</h3><p>CodeGuppy provides an ideal platform for CS teachers and students to engage deeply with programming through meaningful educational projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fffe291408e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeguppy/7-educational-tools-that-you-can-code-yourself-in-javascript-5fffe291408e">7 Educational Tools That You Can Code Yourself in JavaScript</a> was originally published in <a href="https://medium.com/codeguppy">codeguppy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Lesson 02: Pixels and Coordinates]]></title>
            <link>https://medium.com/@adrian_v/cs-curriculum-lesson-02-pixels-and-coordinates-95c9d417626d?source=rss-124201dddc8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/95c9d417626d</guid>
            <dc:creator><![CDATA[Adrian]]></dc:creator>
            <pubDate>Fri, 14 Jul 2023 16:40:00 GMT</pubDate>
            <atom:updated>2023-07-14T16:40:26.186Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this article, we will introduce you to some very important concepts widely used in our JavaScript lessons as well as in computing in general:</p><ul><li>Pixels</li><li>Resolution</li><li>Coordinates</li></ul><p>Don’t be intimidated by these funny words. The concepts behind are very simple.</p><blockquote>At this point we highly recommend you to print this article. By following the exercises from the printed copy, you’ll be forced to use your keyboard to type the programs. This will greatly improve your coding skills!</blockquote><h3>Start Code Editor</h3><p>Let’s start by opening the code editor as explained in the previous article. If you forgot the link it is: <a href="https://codeguppy.com/">https://codeguppy.com</a></p><p>Once you log in, click the “CODE NOW” button in the big area at the top of the main page.</p><p>Alternatively, you can open the editor directly by going to <a href="https://codeguppy.com/code.html">https://codeguppy.com/code.html</a></p><h3>Pixels</h3><p>With the editor in front of you, look on the right side of the screen. That’s your output area also called the “canvas”.</p><p>Although it looks at this moment like a big white surface, the canvas is made up of many small dots that you can turn black or white or even color them through the code. These dots are called pixels.</p><p>In a sense the canvas is like a graph paper (grid paper), with each grid paper square being a tiny pixel on the canvas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*cL0Gv0bBUbzwZKFZ5C3Thg.png" /></figure><h3>Resolution</h3><p>In CodeGuppy the canvas is 800 pixels wide and 600 pixels high.</p><p>This means we have 800 x 600 = 480,000 total pixels on the canvas. That’s way more than the number of squares on a typical grid paper!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*2kEZ_YSSKdV7JGGBCgaw0Q.png" /></figure><p>We refer to these numbers as the resolution of the canvas.</p><p>Note: You probably heard the term resolution before in similar contexts. For instance, a typical HD TV screen has a resolution of 1920x1080, while a 4K TV has 3840x210 (4 times as much pixels as regular HD TV). Similarly, a laptops and tablets have various resolutions such as 1024x768, 1920x1080, etc.</p><h3>Coordinates</h3><p>When we draw a shape or character in CodeGuppy we need to specify where we want to draw it. Do we want to appear in the middle of the screen or a little bit to the left or right?</p><p>We specify this position by “coordinates”.</p><p>Since the canvas is a flat surface we need to use just 2 numbers as coordinates: one for horizontal and one for the vertical:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*WsC75iI7UfCLJB1VznM2Ug.png" /></figure><p>As in many other computer bases systems, CodeGuppy considers the first pixel as being the one in the upper-left corner. This pixel has coordinates (0, 0).</p><p>Note: The first pixel on each direction is pixel “0” not “1”. The second pixel is “1”, the third one “2” and so on. That means that the last pixel that you can address on a given direction is 1 less than the dimension of the canvas on that direction.</p><ul><li>Horizontal: 0–799 (800 pixels in total on horizontal)</li><li>Vertical: 0–599 (600 pixels in total on vertical)</li></ul><p>Note: Even complex shapes such as circles are drawn on the canvas by setting the appropriate pixels (the circle instruction in this case is doing this automatically):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*9DfMRG9YWb7gL5kmkAe9kg.png" /></figure><h3>Playing with coordinates</h3><p>Enough theory! Let’s use some code to turn on some pixels.</p><p>Carefully type the following program in the code editor. Do not change or forget anything!</p><pre>point(0, 0)</pre><pre>point(799, 0)</pre><pre>point(0, 599)</pre><pre>point(799, 599)</pre><p>Can you tell without hitting “Play” what this code is supposed to do?</p><p>Will give you a hint: The `point` instruction is putting a single point on the canvas at the specified coordinates. The first number is the coordinate on horizontal (also called x) and the second number the coordinate on vertical (y).</p><p>Enough guessing! Now run the code (click “Play” button) and look closely in the corners of the canvas to see the pixels. They are small!</p><p>Let’s extend the program to set one more pixel. Go with the cursor at the end of the code and type in addition the following instruction:</p><pre>point(400, 300)</pre><p>Since the canvas resolution is 800x600, the middle of the canvas is approximately at coordinates (400, 300). Therefore, the previous instruction should add one more point in the center of the canvas.</p><p>Run the program and observe the effect.</p><p>If you got an error, you probably have a mistake. We’re including below the entire program that you should have in the code editor. Check carefully each line to spot the error:</p><p>Remark: we’ve also took the opportunity to comment out the code so we can better remember what it does in the future. If you want you can comment your code too.</p><pre>// Corner points</pre><pre>point(0, 0)</pre><pre>point(799, 0)</pre><pre>point(0, 599)</pre><pre>point(799, 599)</pre><pre>// Center point</pre><pre>point( 400, 300 )</pre><h3>Revisiting circle</h3><p>Is time now to revisit the `circle` instruction that we used in the first article:</p><pre>circle(400, 300, 100)</pre><p>Let’s better understand the parameters of this instruction:</p><ul><li>The first 2 parameters are the coordinates of the center of the circle. 400 = the coordinate on horizontal, 300 the coordinate on vertical. As we saw (400, 300) is also the middle of the canvas, that’s why our circle appeared in the middle of the canvas.</li><li>The third parameter is the radius of the circle. The radius is also expressed in pixels</li></ul><h3>Extending the toolbox</h3><p>You have now in your toolbox two instructions that you can use to draw shapes on the canvas: “point” and “circle”.</p><p>Let’s extend this toolbox with two more instructions that you can use to draw a straight lines and rectangles.</p><p><strong>Drawing lines</strong></p><p>The instruction to draw a line is simply called “line” and takes 4 parameters: the x and y coordinates for each end of the line. By specifying the coordinates of each end you can draw a line between any two pixels on the canvas:</p><p>Example:</p><pre>line(250, 100, 550, 100);</pre><pre>line(250, 500, 550, 500);</pre><p><strong>Drawing rectangles</strong></p><p>The instruction for drawing rectangles is called “rect”. The first two parameters specify the coordinates of the top-left corner, while the other two parameters, specify the width and height of the rectangle.</p><p>Example:</p><pre>rect(250, 200, 300, 200);</pre><p>Let’s quickly combine these instructions in a simple program to see their effect. Start first a new program and then type these lines:</p><pre>line(250, 100, 550, 100);</pre><pre>line(250, 500, 550, 500);</pre><pre>rect(250, 200, 300, 200);</pre><p>Run the code to see the effect. Can you now change the coordinates of the lines so are displayed on vertical rather than horizontal?</p><h3>Fun drawing</h3><p>Let’s draw with code!</p><p>We’ll use the instructions in our toolbox: line, rect and circle to draw a house on the canvas!</p><p><strong>Planning the drawing</strong></p><p>On a blank piece of paper draw a big rectangle. That’s your canvas.</p><p>Inside the rectangle, try to reproduce the following house using only straight lines and circles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*SwpuqeOu11okQ2o3oUkoNw.png" /></figure><p>Next identify what will be the coordinates for each line, rectangle and circle… (approximations are fine).</p><p>Take your time! Take notes and even draft the program on the paper. By doing this exercise you’ll improve your understanding about coordinates.</p><p><strong>Coding the house</strong></p><p>When you’re done with paper design you can start typing the code in the code editor.</p><p>As soon as you typed your first instruction, hit ‘Play’ to check the effect. Adjust coordinates if necessary. Continue in this way until you finished your entire drawing.</p><p>Remember: If you realized a master-piece and you want to keep it, hit the ‘Save’ button in the upper-right corner.</p><h3>Our version</h3><p>We strongly recommend you practice coding and try building the program that draws the house. Practicing is essential in coding!</p><p>However, if after 1 hour of hard work you still don’t have a house, is time to check our code below.</p><p>Ta da!!!</p><p>This is our code to draw the house:</p><pre>// House</pre><pre>// Draw walls</pre><pre>rect(250, 250, 300, 300);</pre><pre>// Draw roof</pre><pre>line(250, 250, 400, 100);</pre><pre>line(400, 100, 550, 250);</pre><pre>circle(400, 195, 30);</pre><pre>// Draw chimney</pre><pre>line(480, 180, 480, 120);</pre><pre>line(480, 120, 500, 120);</pre><pre>line(500, 120, 500, 200);</pre><pre>// Draw left window</pre><pre>rect(275, 275, 100, 100);</pre><pre>line(275, 325, 375, 325);</pre><pre>line(325, 275, 325, 375);</pre><pre>// Draw right window</pre><pre>rect(425, 275, 100, 100);</pre><pre>line(425, 325, 525, 325);</pre><pre>line(475, 275, 475, 375);</pre><pre>// Draw door</pre><pre>rect(350, 425, 100, 125);</pre><pre>// Draw smoke</pre><pre>circle(520, 110, 10);</pre><pre>circle(550, 90, 15);</pre><pre>circle(600, 60, 25);</pre><p>Compare it with your code and then with the original sketch.</p><p>We did also a lot of approximations when we came up with the coordinates.</p><p>If you are not tired already, try to type the code in a new CodeGuppy program.</p><blockquote>Although this long program may tempt you to copy and paste it from this article, we strongly recommend you type the program using your keyboard. It will better help you remember the commands and also practice coding.</blockquote><h3>Conclusion</h3><p>We hope you liked this article about pixels, resolution and coordinates.</p><p>With this knowledge, you can now master the art of drawing with code. Can you take as a challenge to:</p><ul><li>draw a car?</li><li>draw a stick person?</li><li>draw your name with lines?</li></ul><p>Have fun and please share your masterpieces in the comments of this article. Yes — that’s right: you can share your programs with anyone by providing the link to that program. Please use the “Share” button in CodeGuppy to obtain the link.</p><p>Note: This article is also available as an interactive tutorial at <a href="https://codeguppy.com/code.html?t=_coordinates">https://codeguppy.com/code.html?t=_coordinates</a></p><p>Until next time: Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95c9d417626d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>