<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Kat  🐆🐾</title>
    <description>The latest articles on Forem by Kat  🐆🐾 (@codebalance).</description>
    <link>https://forem.com/codebalance</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F47815%2F711a7d2e-7aae-4251-934d-626feee0838e.jpg</url>
      <title>Forem: Kat  🐆🐾</title>
      <link>https://forem.com/codebalance</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/codebalance"/>
    <language>en</language>
    <item>
      <title>Learning GO with Codeacademy</title>
      <dc:creator>Kat  🐆🐾</dc:creator>
      <pubDate>Sat, 28 Nov 2020 18:22:23 +0000</pubDate>
      <link>https://forem.com/codebalance/learning-go-with-codeacademy-41ip</link>
      <guid>https://forem.com/codebalance/learning-go-with-codeacademy-41ip</guid>
      <description>&lt;h1&gt;
  
  
  Introduction &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Go was developed at Google with the goal to &lt;a href="https://talks.golang.org/2012/splash.artcicle" rel="noopener noreferrer"&gt;eliminate the slowness and clumsiness of software development at Google, and thereby to make the process more productive and scalable&lt;/a&gt;. In other words, Go is supposed to make development faster and easier for developers.&lt;/p&gt;

&lt;p&gt;It has modern features like garbage collection and also takes advantage of multi-core computer capabilities with built-in concurrency support. &lt;/p&gt;

&lt;p&gt;Read up on &lt;a href="https://dev.to/pavanbelagatti/why-is-go-so-damn-popular-among-developers-2d6h"&gt;why Go has become popular&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.codecademy.com/learn/learn-go/modules/learn-go-introduction/cheatsheet" rel="noopener noreferrer"&gt;Go Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.codecademy.com/articles/setting-up-go-locally" rel="noopener noreferrer"&gt;Setting up Go locally&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://golang.org/pkg/" rel="noopener noreferrer"&gt;List of Go's standard packages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://golang.org/" rel="noopener noreferrer"&gt;Golang.org&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other learning resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://tour.golang.org/welcome/1" rel="noopener noreferrer"&gt;A Tour of Go&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://golang.org/doc/effective_go.html" rel="noopener noreferrer"&gt;Effective Go&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://golang.org/ref/spec" rel="noopener noreferrer"&gt;The Go Programming Language Specification&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.gopl.io/" rel="noopener noreferrer"&gt;The Go Programming Language&lt;/a&gt; (book)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Compiling &amp;amp; Running Files &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A compiler translates Go code into an &lt;em&gt;executable&lt;/em&gt;/&lt;em&gt;binary&lt;/em&gt; file. &lt;/p&gt;

&lt;p&gt;Compile and run a file called &lt;code&gt;file_name.go&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go build file_name.go
./file_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, using &lt;code&gt;go run&lt;/code&gt; does combine both compilation and execution of code, but does not create an executable file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go run file_name.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Basic Go Structure: Packages &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Let's look at the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;package main&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;This is a package declaration.&lt;/li&gt;
&lt;li&gt;Every Go program starts with one.&lt;/li&gt;
&lt;li&gt;It informs the compiler whether to create an executable or &lt;em&gt;library&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;A library doesn't execute code. It is a collection of code that can be used in other programs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;package main&lt;/code&gt; creates an executable file.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;
&lt;code&gt;import "fmt"&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;import&lt;/code&gt; imports code from other packages&lt;/li&gt;
&lt;li&gt;Packages are enclosed with double quotes &lt;code&gt;"&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;
&lt;code&gt;func main() {...}&lt;/code&gt; 

&lt;ul&gt;
&lt;li&gt;While we define the &lt;code&gt;main&lt;/code&gt; function, we never explicitly tell &lt;code&gt;main&lt;/code&gt; to run its block of code.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;main&lt;/code&gt; function is special: a file that has a &lt;code&gt;package main&lt;/code&gt; declaration will automatically run the &lt;code&gt;main&lt;/code&gt; function&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Importing Multiple Packages &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To import multiple packages, we can write&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"package1"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"package2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;"package1"&lt;/span&gt;
  &lt;span class="s"&gt;"package2"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Providing an &lt;em&gt;alias&lt;/em&gt; to a package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;p1&lt;/span&gt; &lt;span class="s"&gt;"package1"&lt;/span&gt;
  &lt;span class="s"&gt;"package2"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using an alias, we can call functions from &lt;code&gt;package1&lt;/code&gt; by using &lt;code&gt;p1&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;p1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SampleFunc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;package1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SampleFunc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Comments &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Go encourages the use of comments for describing what functions do. It gets used by &lt;a href="https://github.com/golang/go/wiki/Comments" rel="noopener noreferrer"&gt;Go's documentation tool&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// This is a comment&lt;/span&gt;
&lt;span class="c"&gt;/*
This is a multiline
comment.
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Go Resources &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Go has a built-in documentation system. Use the command &lt;code&gt;go doc&lt;/code&gt; followed by a package name, e.g.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go doc &lt;span class="nb"&gt;fmt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get more specific information about a function in a package, e.g:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go doc fmt.Println
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: The capitalization of the function doesn't matter, this will also work: &lt;code&gt;go doc fmt.println&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fun Application &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;gopher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
&lt;span class="s"&gt;"      `.-::::::-.`&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"  .:-::::::::::::::-:.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"  `_:::    ::    :::_`&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"   .:( ^   :: ^   ):.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"   `:::   (..)   :::.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"   `:::::::UU:::::::`&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"   .::::::::::::::::.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"   O::::::::::::::::O&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"   -::::::::::::::::-&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"   `::::::::::::::::`&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"    .::::::::::::::.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"      oO:::::::Oo&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;

  &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;dog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
&lt;span class="s"&gt;"  __      _&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;"o'')}____//&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;" `_/      )&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
&lt;span class="s"&gt;" (_(_/-(_/&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gopher&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dog&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Variables and Formatting &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Example program showing &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;string&lt;/li&gt;
&lt;li&gt;number (&lt;code&gt;int8&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;boolean
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;stationName&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;nextTrainTime&lt;/span&gt; &lt;span class="kt"&gt;int8&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;isUptownTrain&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;

  &lt;span class="n"&gt;stationName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Union Square"&lt;/span&gt;
  &lt;span class="n"&gt;nextTrainTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;12&lt;/span&gt;
  &lt;span class="n"&gt;isUptownTrain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;

  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Current station:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stationName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Next train:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nextTrainTime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"minutes"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Is uptown:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;isUptownTrain&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Literals   &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Literals are values written into code "as they are", e.g. &lt;code&gt;109&lt;/code&gt;, or &lt;code&gt;"hello world"&lt;/code&gt;. They are &lt;em&gt;unnamed&lt;/em&gt; values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Constants and Variables
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Constants cannot be updated while the program is running. &lt;/li&gt;
&lt;li&gt;Variables can update their value
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;earthsGravity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;9.80665&lt;/span&gt;

  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;earthsGravity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Basic Data Types in Go
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;int&lt;/li&gt;
&lt;li&gt;float&lt;/li&gt;
&lt;li&gt;complex&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Basic Numeric Types in Go
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0kmcb3h9g63i88ezjfnz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0kmcb3h9g63i88ezjfnz.png" alt="Screen Shot 2020-11-22 at 6.11.07 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://golang.org/ref/spec#Numeric_types" rel="noopener noreferrer"&gt;Numeric types documentation&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  What is a Variable?
&lt;/h3&gt;

&lt;p&gt;Variables are defined with the &lt;code&gt;var&lt;/code&gt; keyword and two pieces of information: the name that we will use to refer to them and the type of data stored in the variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;lengthOfSong&lt;/span&gt; &lt;span class="kt"&gt;uint16&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;isMusicOver&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;songRating&lt;/span&gt; &lt;span class="kt"&gt;float32&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can declare and assign a variable in one line, with or without declaring the type specifically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Kat"&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;middleName&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Xenia"&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;", "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;middleName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Zero Values
&lt;/h3&gt;

&lt;p&gt;Even before we assign anything to our variables they hold a value. Go's designers attempted to make these "sensible defaults" that we can anticipate based on the variable's types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;classTime&lt;/span&gt; &lt;span class="kt"&gt;uint32&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;averageGrade&lt;/span&gt; &lt;span class="kt"&gt;float32&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;teacherName&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;isPassFail&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;

&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;classTime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints 0&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;averageGrade&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints 0&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;teacherName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Doesn't print anything, default: ""&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isPassFail&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Inferring Type
&lt;/h3&gt;

&lt;p&gt;There is a way to declare a variable without explicitly stating its type using the short declaration &lt;code&gt;:=&lt;/code&gt; operator. We might use the &lt;code&gt;:=&lt;/code&gt; operator if we know what value we want our variable to store when creating it.&lt;/p&gt;

&lt;p&gt;The following defines a &lt;code&gt;bool&lt;/code&gt;, &lt;code&gt;float&lt;/code&gt;, &lt;code&gt;int&lt;/code&gt;, and &lt;code&gt;string&lt;/code&gt; without specifying the type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;nuclearMeltdownOccurring&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;radiumInGroundWater&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;4.521&lt;/span&gt;
&lt;span class="n"&gt;daysSinceLastWorkplaceCatastrophe&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;externalMessage&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"Everything is normal. Keep calm and carry on."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Floats created this way are of type &lt;code&gt;float64&lt;/code&gt;. Integers created this way are either &lt;code&gt;int32&lt;/code&gt; or &lt;code&gt;int64&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;An alternative syntax to declare a variable and infer its type is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;nuclearMeltdownOccurring&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;radiumInGroundWater&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;4.521&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;daysSinceLastWorkplaceCatastrophe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;externalMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Everything is normal. Keep calm and carry on."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Default int Type
&lt;/h3&gt;

&lt;p&gt;There is one more common way to define an &lt;code&gt;int&lt;/code&gt; in Go. Computers actually have a default length for the data in the Read-Only Memory (ROM). Some newer computers may have more processing power and can store/handle bigger chunks of data. These computers might be using a 64-bit architecture, but other computers still run on 320bit architecture and work just fine.&lt;/p&gt;

&lt;p&gt;By providing the type &lt;code&gt;int&lt;/code&gt; or &lt;code&gt;uint&lt;/code&gt;, Go will check to see if the computer architecture is running on is 32-bit or 64-bit. Then it will either provide a 32-bit &lt;code&gt;int&lt;/code&gt; (or &lt;code&gt;uint&lt;/code&gt;) or a 64-bit one depending on the computer itself. &lt;/p&gt;

&lt;p&gt;It is recommended to use &lt;code&gt;int&lt;/code&gt; unless there's a reason to specify the size of the int (like knowing that value will be larger than the default type, or needing to optimize the amount of space used).&lt;/p&gt;

&lt;p&gt;The following two variables are integers of either 32 or 64 bits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;timesWeWereFooled&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;foolishGamesPlayed&lt;/span&gt; &lt;span class="kt"&gt;uint&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a variable is declared and assigned a value using the &lt;code&gt;:=&lt;/code&gt; operator, it will be the same type as if it were declared as an &lt;code&gt;int&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;consolationPrizes&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Multiple Variable Declaration
&lt;/h3&gt;

&lt;p&gt;There are more than one way to declare multiple variables on a single line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;part1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;part2&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="n"&gt;part1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"To be..."&lt;/span&gt;
&lt;span class="n"&gt;part2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Not to be..."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fact&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"Bears, Beets, Battlestar Galactica"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints: Bears, Beets, Battlestar Galactica&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fact&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints: true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  The fmt Package
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;fmt&lt;/code&gt; is one of Go's core packages. It helps &lt;em&gt;format&lt;/em&gt; data, which is why it's sometimes referred to as the format package.&lt;/p&gt;

&lt;p&gt;There are a few methods in the &lt;a href="https://golang.org/pkg/fmt/" rel="noopener noreferrer"&gt;&lt;code&gt;fmt&lt;/code&gt; package&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Printing data to the terminal

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Println()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Print()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Printf()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Formatting (without printing to the terminal)

&lt;ul&gt;
&lt;li&gt;Sprint()&lt;/li&gt;
&lt;li&gt;Sprintln()&lt;/li&gt;
&lt;li&gt;Sprintf()&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Getting user input

&lt;ul&gt;
&lt;li&gt;Scan()&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Print Method
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;fmt.Println()&lt;/code&gt; allows us to print to the terminal. It has some default styling built-in that makes viewing data easier. &lt;code&gt;fmt.Println()&lt;/code&gt; prints its &lt;em&gt;arguments&lt;/em&gt; with an included space in between each argument and adds a line break at the end.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Println"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"formats"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"really well"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Right?"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Println formats really well
Right?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the case that default formatting is not wanted, &lt;code&gt;fmt.Print()&lt;/code&gt; is more appropriate. It does not add default spacing, nor a line break.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Printf Method
&lt;/h3&gt;

&lt;p&gt;Using &lt;code&gt;fmt.Println()&lt;/code&gt; and &lt;code&gt;fmt.Print()&lt;/code&gt;, we have the ability to concatenate strings, i.e. combine different strings into a single string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"C"&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Is"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"your final answer?"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Prints: Is C your final answer?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;fmt.Printf()&lt;/code&gt;, we can &lt;em&gt;interpolate&lt;/em&gt; strings, or leave placeholders in a string and use values to fill in the placeholders.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;selection1&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"soup"&lt;/span&gt;
&lt;span class="n"&gt;selection2&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"salad"&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Do I want %v or %v?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;selection1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;selection2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Prints: Do I want soup or salad?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;%v&lt;/code&gt; in the string is the placeholder and known as a &lt;em&gt;verb&lt;/em&gt; in Go.&lt;/p&gt;

&lt;h3&gt;
  
  
  Different Verbs
&lt;/h3&gt;

&lt;p&gt;In addition to &lt;code&gt;%v&lt;/code&gt;, Go has a variety of &lt;a href="https://golang.org/pkg/fmt/#hdr-Printing" rel="noopener noreferrer"&gt;useful verbs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Example: &lt;code&gt;%T&lt;/code&gt; prints out the type of a variable&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;specialNum&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;42&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"This value's type is %T."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;specialNum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Prints: This value's type is int.&lt;/span&gt;

&lt;span class="n"&gt;quote&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"To do or not to do"&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"This value's type is %T."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Prints: This value's type is string.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example: &lt;code&gt;%d&lt;/code&gt; interpolates a number into a strgin&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;votingAge&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;18&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You must be %d years old to vote."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;votingAge&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Prints: You must be 18 years old to vote. &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example: &lt;code&gt;%f&lt;/code&gt; interpolates a float into a string, with the option to limit the precision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;gpa&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;3.8&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You're averaging: %f."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gpa&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Prints: You're averaging 3.800000.&lt;/span&gt;

&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You're averaging: %.2f."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gpa&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Prints: You're averaging 3.80.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Sprint and Sprintln
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;fmt.Sprint()&lt;/code&gt; and &lt;code&gt;fmt.Sprintln()&lt;/code&gt; format strings instead of printing them out. &lt;/p&gt;

&lt;p&gt;The following example shows how &lt;code&gt;fmt.Sprint()&lt;/code&gt; returns a value that can be stored in a variable and used later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"100"&lt;/span&gt;
&lt;span class="n"&gt;compliment&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"Great job!"&lt;/span&gt;
&lt;span class="n"&gt;teacherSays&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Sprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You scored a "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;grade&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;" on the test! "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;compliment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;teacherSays&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Prints: You scored a 100 on the test! Great job!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;fmt.Sprint()&lt;/code&gt; doesn't include spaces or newline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;quote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Sprintln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Look ma,"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"no spaces!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints Look ma, no spaces!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Sprintf Method
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;fmt.Sprintf()&lt;/code&gt; uses verbs just like &lt;code&gt;fmt.Printf()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;  &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"I wish I had a %v."&lt;/span&gt;
  &lt;span class="n"&gt;pet&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"puppy"&lt;/span&gt;

  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;wish&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;

  &lt;span class="c"&gt;// Add your code below:&lt;/span&gt;
  &lt;span class="n"&gt;wish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Sprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wish&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Scan(): Getting User Input
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"How are you doing?"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 

&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; 
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"I'm %v."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;fmt.Scan()&lt;/code&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reads in a string up until a whitespace&lt;/li&gt;
&lt;li&gt;expects &lt;em&gt;addresses&lt;/em&gt; for arguments&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Conditionals
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;if&lt;/code&gt; statement does not necessarily need parentheses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;alarmRinging&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;alarmRinging&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Turn off the alarm!!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;isHungry&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isHungry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Eat the cookie"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Step away from the cookie..."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Comparison &amp;amp; Logical Operators
&lt;/h3&gt;

&lt;p&gt;To use a comparison operator, we have two values (or &lt;em&gt;operands&lt;/em&gt;) with a comparison operator in between the two values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"Saturday"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"Sunday"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Enjoy the weekend!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Do some work."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  else if Statement
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;position&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;position&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You won the gold!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;position&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You got the silver medal."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;position&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Great job on bronze."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Sorry, better luck next time?"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  switch Statement
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;clothingChoice&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"sweater"&lt;/span&gt;

&lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="n"&gt;clothingChoice&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;"shirt"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"We have shirts in S and M only."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;"polos"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"We have polos in M, L, and XL."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;"sweater"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"We have sweaters in S, M, L, and XL."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;"jackets"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"We have jackets in all sizes."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Sorry, we don't carry that"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;// Prints: We have sweaters in S, M, L, and XL.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Scoped Short Declaration Statement
&lt;/h3&gt;

&lt;p&gt;We can provide a short variable declaration before we provide a condition in either &lt;code&gt;if&lt;/code&gt; or &lt;code&gt;switch&lt;/code&gt; statements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;8&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;9&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;60&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"  is greater than 60"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that the variable declaration is separated from the condition using a semi-colon &lt;code&gt;;&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="n"&gt;season&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"summer"&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;season&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;"summer"&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Go out and enjoy the sun!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The variable that is declared using the short variable declaration is &lt;em&gt;scoped&lt;/em&gt; to the statement blocks. This means that the variable is only accessible within the blocks of those statements and not anywhere else.&lt;/p&gt;

&lt;p&gt;This code will throw an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;8&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;9&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;60&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"  is greater than 60"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Randomizing
&lt;/h3&gt;

&lt;p&gt;Go has a &lt;code&gt;math/rand&lt;/code&gt; library that has methods to generate random numbers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;"math/rand"&lt;/span&gt;
  &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rand&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Intn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;rand.Intn()&lt;/code&gt; method takes an argument, which is the maximum value that the method will return.  It will return a random integer from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;100&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Seeding
&lt;/h3&gt;

&lt;p&gt;Go &lt;em&gt;seeds&lt;/em&gt; (chooses) a number as a starting point for generating random numbers. By default, the seed value is &lt;code&gt;1&lt;/code&gt;. We can provide a new seed value using the method &lt;code&gt;rand.Seed()&lt;/code&gt; and passing in an integer.&lt;/p&gt;

&lt;p&gt;The seed number should always be a unique number, which can be achieved using time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;"fmt"&lt;/span&gt;
  &lt;span class="s"&gt;"math/rand"&lt;/span&gt;
  &lt;span class="s"&gt;"time"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;rand&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Seed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UnixNano&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rand&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Intn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;time.Now().UnixNano()&lt;/code&gt; results in the difference in time (in nanoseconds) since January 1st, 1970 UTC. Check out the &lt;a href="https://golang.org/pkg/time/#Time.UnixNano" rel="noopener noreferrer"&gt;UnixNano documentation&lt;/a&gt; for more details.&lt;/p&gt;

&lt;h1&gt;
  
  
  Functions
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;doubleNum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;call site&lt;/em&gt; is the place where a function is called. Values that are returned from functions are set from within the function to the call site. A function can be given a return &lt;em&gt;type&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;getLengthOfCentralPark&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kt"&gt;int32&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;lengthInBlocks&lt;/span&gt; &lt;span class="kt"&gt;int32&lt;/span&gt;
  &lt;span class="n"&gt;lengthInBlocks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;51&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;lengthInBlocks&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Function parameters are variables that are used within the function. When calling a function, we give &lt;em&gt;arguments&lt;/em&gt;, which are the values that we want those parameter variables to take.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;multiplier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="kt"&gt;int32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="kt"&gt;int32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;int32&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since both parameters in the function above are the same, we could write it as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;multiplier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="kt"&gt;int32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;int32&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Scope
&lt;/h3&gt;

&lt;p&gt;Scope keeps the &lt;em&gt;namespace&lt;/em&gt;, the available variables and keywords, cleaner. Variables or functions can only be referred to in their respective namespace.&lt;/p&gt;

&lt;h3&gt;
  
  
  Multiple Return Values
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;GPA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;midtermGrade&lt;/span&gt; &lt;span class="kt"&gt;float32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;finalGrade&lt;/span&gt; &lt;span class="kt"&gt;float32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;float32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;averageGrade&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;midtermGrade&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;finalGrade&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;gradeLetter&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;averageGrade&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;90&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;gradeLetter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"A"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;averageGrade&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;80&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;gradeLetter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"B"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;averageGrade&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;70&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;gradeLetter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"C"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;averageGrade&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;60&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;gradeLetter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"D"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;gradeLetter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"F"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;gradeLetter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;averageGrade&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;myMidterm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;myFinal&lt;/span&gt; &lt;span class="kt"&gt;float32&lt;/span&gt;
  &lt;span class="n"&gt;myMidterm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;89.4&lt;/span&gt;
  &lt;span class="n"&gt;myFinal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;74.9&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;myAverage&lt;/span&gt; &lt;span class="kt"&gt;float32&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;myGrade&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
  &lt;span class="n"&gt;myGrade&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;myAverage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;GPA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myMidterm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;myFinal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myAverage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;myGrade&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints 82.12 B&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deferring Resolution
&lt;/h3&gt;

&lt;p&gt;We can delay a function call to the end of the current scope by using the &lt;code&gt;defer&lt;/code&gt; keyword. &lt;code&gt;defer&lt;/code&gt; tells Go to run a function, but at the end of the current function. This is useful for logging, file writing, and other utilities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;calculateTaxes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;revenue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deductions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;credits&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Taxes Calculated!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;taxRate&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;.06143&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Calculating Taxes"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;deductions&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;credits&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;revenue&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;taxRate&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;


  &lt;span class="n"&gt;taxValue&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;revenue&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deductions&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;credits&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;taxRate&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;taxValue&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;taxValue&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, the first print statement is being deferred. Normally, we would consider adding the print statement at the end of the function. But given that there are multiple &lt;code&gt;return&lt;/code&gt; statements, instead of adding the same print statement before each return, &lt;code&gt;defer&lt;/code&gt; can be used to print it regardless of when the function ends.&lt;/p&gt;

&lt;h1&gt;
  
  
  Addresses and Pointers
&lt;/h1&gt;

&lt;p&gt;Go is a &lt;em&gt;pass-by-value&lt;/em&gt; language, but it is possible to change values from different scopes using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Addresses&lt;/li&gt;
&lt;li&gt;Pointers&lt;/li&gt;
&lt;li&gt;Dereferencing
### Addresses
To find a variable's address we use the &lt;code&gt;&amp;amp;&lt;/code&gt; operator followed by the variable name:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"My very first address"&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints 0x414020&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pointers
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Pointers&lt;/em&gt; are used to store addresses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pointerForInt&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;*&lt;/code&gt; operator signifies that this variable will store an address and the &lt;code&gt;int&lt;/code&gt; portion means that the address contains an integer value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pointerForInt&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;

&lt;span class="n"&gt;minutes&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;525600&lt;/span&gt;

&lt;span class="n"&gt;pointerForInt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;minutes&lt;/span&gt;

&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pointerForInt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints 0xc000018038&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Declare a pointer implicitly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;minutes&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;55&lt;/span&gt;

&lt;span class="n"&gt;pointerForInt&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;minutes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Dereferencing
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Dereferencing&lt;/em&gt; or &lt;em&gt;indirecting&lt;/em&gt; refers to accessing the value at a given address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;lyrics&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"Moments so dear"&lt;/span&gt; 
&lt;span class="n"&gt;pointerForStr&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;lyrics&lt;/span&gt;

&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;pointerForStr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Journeys to plan"&lt;/span&gt; 

&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lyrics&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints: Journeys to plan&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Changing Values in Different Scopes
&lt;/h3&gt;

&lt;p&gt;By passing the value of a pointer, we can dereference the address and change the value in the function. The function call needs to pass in the address of the variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;addHundred&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numPtr&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;numPtr&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
  &lt;span class="n"&gt;addHundred&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Prints 101&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>go</category>
      <category>codeacademy</category>
      <category>beginners</category>
    </item>
    <item>
      <title>DS &amp; Algos for Interviewing in Python</title>
      <dc:creator>Kat  🐆🐾</dc:creator>
      <pubDate>Wed, 09 Sep 2020 13:18:47 +0000</pubDate>
      <link>https://forem.com/codebalance/ds-algos-for-interviewing-in-python-24b4</link>
      <guid>https://forem.com/codebalance/ds-algos-for-interviewing-in-python-24b4</guid>
      <description>&lt;p&gt;I am preparing to interview at FANG companies, and am reviewing the material I've learned at the &lt;a href="https://www.udacity.com/course/data-structures-and-algorithms-nanodegree--nd256"&gt;Data Structures &amp;amp; Algorithms Nanodegree&lt;/a&gt; at Udacity.&lt;/p&gt;

&lt;p&gt;Here's an overview of the topics that are covered in the Nanodegree:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Introduction

&lt;ol&gt;
&lt;li&gt;Python Refresher&lt;/li&gt;
&lt;li&gt;How to Solve Problems&lt;/li&gt;
&lt;li&gt;Efficiency&lt;/li&gt;
&lt;li&gt;-- Solve some problems --&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;Data Structures

&lt;ol&gt;
&lt;li&gt;Arrays &amp;amp; Linked Lists&lt;/li&gt;
&lt;li&gt;Stacks &amp;amp; Queues&lt;/li&gt;
&lt;li&gt;Recursion&lt;/li&gt;
&lt;li&gt;Trees&lt;/li&gt;
&lt;li&gt;Maps and Hashing&lt;/li&gt;
&lt;li&gt;-- Solve some problems --&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;Basic Algorithms

&lt;ol&gt;
&lt;li&gt;Basic Algorithms&lt;/li&gt;
&lt;li&gt;Sorting Algorithms&lt;/li&gt;
&lt;li&gt;Faster Divide &amp;amp; Conquer Algorithms&lt;/li&gt;
&lt;li&gt;-- Solve some problems --&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;Advanced Algorithms

&lt;ol&gt;
&lt;li&gt;Greedy Algorithms&lt;/li&gt;
&lt;li&gt;Graph Algorithms&lt;/li&gt;
&lt;li&gt;Dynamic Programming&lt;/li&gt;
&lt;li&gt;A*&lt;/li&gt;
&lt;li&gt;-- Implement A* --&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This blog series is the place where I'm planning to collect and save materials for future reference.&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>interviewing</category>
      <category>datascience</category>
    </item>
    <item>
      <title>ELI5: Database Normalization?</title>
      <dc:creator>Kat  🐆🐾</dc:creator>
      <pubDate>Sat, 07 Dec 2019 13:43:46 +0000</pubDate>
      <link>https://forem.com/codebalance/eli5-database-normalization-4ba3</link>
      <guid>https://forem.com/codebalance/eli5-database-normalization-4ba3</guid>
      <description>&lt;p&gt;Dear fellow devs 👋🏻,&lt;/p&gt;

&lt;p&gt;🤓 I just started learning about databases, took the &lt;a href="https://mode.com/sql-tutorial/"&gt;mode SQL tutorial&lt;/a&gt; and am taking a &lt;a href="https://www.udacity.com/course/full-stack-web-developer-nanodegree--nd0044"&gt;course on Fullstack Web Development&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;👩🏻‍🎓 At some point, I will take a deep dive into &lt;a href="https://www.udacity.com/course/database-systems-concepts-design--ud150"&gt;database design&lt;/a&gt;, but for now, can you help me get a general idea of database normalization? &lt;/p&gt;

&lt;p&gt;🤔What does it mean when a table is in first, second, or third normal form (1NF, 2NF, 3NF)?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br&gt;
Kat 🐱🐾&lt;/p&gt;

</description>
      <category>explainlikeimfive</category>
      <category>database</category>
      <category>design</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Learn in Public: Data Structures &amp; Algorithms in Python</title>
      <dc:creator>Kat  🐆🐾</dc:creator>
      <pubDate>Wed, 20 Nov 2019 02:21:05 +0000</pubDate>
      <link>https://forem.com/codebalance/learn-in-public-data-structures-algorithms-in-python-5eaj</link>
      <guid>https://forem.com/codebalance/learn-in-public-data-structures-algorithms-in-python-5eaj</guid>
      <description>&lt;p&gt;I am currently working on becoming more proficient in Data Structures and Algorithms - both for the sake of interviewing and to become a better engineer.&lt;/p&gt;

&lt;p&gt;In the following weeks and months, I'll share with you what I've learned along my journey. The content will include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The theory and application of Data Structures &amp;amp; Algorithms.&lt;/li&gt;
&lt;li&gt;My interviewing experience, tips, and tricks.&lt;/li&gt;
&lt;li&gt;Fun problems you can solve using what we've learned.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;❗️&lt;em&gt;Please share any additional resources that you'd recommend, and topics that I forgot to add in the comments below!&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Learning Method
&lt;/h3&gt;

&lt;p&gt;I love learning, but I am not an efficient student. I am great at "consuming" material, like taking courses and going through tutorials. But if you ask me to explain what I've learned, I wouldn't be able to do so. I would say "it just slips my mind", but truth be told I never do the work to commit the material into my long term memory.&lt;/p&gt;

&lt;p&gt;This time it is going to be different, and I am going to utilize the following two strategies to improve my retention of what I've learned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use scientific methods for &lt;a href="https://dev.to/codebalance/upgrade-your-learning-an-example-study-plan-for-data-structures-and-algorithms-5he"&gt;efficient learning&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Following the idea of &lt;a href="https://dev.to/miku86/learn-in-public-4jl2"&gt;learning in public&lt;/a&gt;, I am going to summarize and share what I'm learning along the way. Learning by teaching makes sure you truly understand the material.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  List of Resources
&lt;/h2&gt;

&lt;p&gt;For now, let's start with a summary of resources and a list of topics we'll cover in the following weeks and months. &lt;/p&gt;

&lt;p&gt;This is not an exhaustive list of all the resources that are available on the WWW, but rather a list of courses I find intriguing, and the books I own.&lt;/p&gt;

&lt;p&gt;Legend to indicate where I'm at:&lt;br&gt;
❗️: Currently working on&lt;br&gt;
✅: Done&lt;br&gt;
💤: Done, but needs a refresher&lt;/p&gt;

&lt;p&gt;This is a living list, meaning I'll be coming back and updating it as I work through the material.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Structure &amp;amp; Algorithm Courses
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Coursera

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/specializations/algorithms"&gt;Algorithms Specialization&lt;/a&gt;, Stanford&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/specializations/data-structures-algorithms"&gt;Data Structures &amp;amp; Algorithms Specialization&lt;/a&gt;, University of California San Diego&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/learn/algorithms-part1"&gt;Algorithms, Part I&lt;/a&gt;, Princeton University 💤&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/learn/algorithms-part2"&gt;Algorithms, Part II&lt;/a&gt;, Princeton University&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Udacity

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.udacity.com/course/data-structures-and-algorithms-nanodegree--nd256"&gt;Data Structures &amp;amp; Algorithms Nanodegree&lt;/a&gt; ✅&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Books
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Theory

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.goodreads.com/book/show/108986.Introduction_to_Algorithms"&gt;Introduction to Algorithms&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.goodreads.com/book/show/22847284-grokking-algorithms-an-illustrated-guide-for-programmers-and-other-curio?from_search=true&amp;amp;qid=QFldwVIhkg&amp;amp;rank=1"&gt;Grokking Algorithms: An illustrated guide for programmers and other curious people&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Practice Problems

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.goodreads.com/book/show/12544648-cracking-the-coding-interview?ac=1&amp;amp;from_search=true&amp;amp;qid=ahksNnxJ0I&amp;amp;rank=2"&gt;Cracking the Coding Interview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.goodreads.com/book/show/44151058-daily-coding-problem?ac=1&amp;amp;from_search=true&amp;amp;qid=kfqKCpFN6s&amp;amp;rank=1"&gt;Daily Coding Problem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.goodreads.com/book/show/16253895-elements-of-programming-interviews?from_search=true&amp;amp;qid=fPpgfMxaD6&amp;amp;rank=1"&gt;Elements of Programming Interviews&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.goodreads.com/book/show/154154.Programming_Interviews_Exposed"&gt;Programming Interviews Exposed&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Websites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://app.codesignal.com/signup/BCTXJe6pi89ruzqdr/main"&gt;CodeSignal&lt;/a&gt; ❗️&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.pramp.com/invt/oAJ6gVQgxptApdovYQjr"&gt;Pramp&lt;/a&gt;, these are actual mock interviews with real people. You get to experience both sides: Being the interviewee as well as interviewing your peers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Content
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Analyzing Algorithms

&lt;ul&gt;
&lt;li&gt;Asymptotic Notation&lt;/li&gt;
&lt;li&gt;Amortized Analysis&lt;/li&gt;
&lt;li&gt;Probabilistic Analysis &amp;amp; Randomized Algorithms&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Data Structures

&lt;ul&gt;
&lt;li&gt;Arrays &amp;amp; Linked Lists ❗️&lt;/li&gt;
&lt;li&gt;Stacks &amp;amp; Queues&lt;/li&gt;
&lt;li&gt;Hash Tables&lt;/li&gt;
&lt;li&gt;Trees&lt;/li&gt;
&lt;li&gt;Binary Search Trees&lt;/li&gt;
&lt;li&gt;Red-Black Trees&lt;/li&gt;
&lt;li&gt;B-Trees&lt;/li&gt;
&lt;li&gt;Binomial Trees &amp;amp; Binomial Heaps&lt;/li&gt;
&lt;li&gt;Fibonacci Heaps&lt;/li&gt;
&lt;li&gt;Data Structures for Disjoint Sets&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Recursion&lt;/li&gt;
&lt;li&gt;Sorting &amp;amp; Order Algorithms

&lt;ul&gt;
&lt;li&gt;Heapsort&lt;/li&gt;
&lt;li&gt;Quicksort&lt;/li&gt;
&lt;li&gt;Sorting in Linear Time&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Graph Algorithms

&lt;ul&gt;
&lt;li&gt;Breadth-first search (BFS)&lt;/li&gt;
&lt;li&gt;Depth-first search (DFS)&lt;/li&gt;
&lt;li&gt;Topological Sort&lt;/li&gt;
&lt;li&gt;Minimum Spanning Trees&lt;/li&gt;
&lt;li&gt;Single-Source Shortest Paths&lt;/li&gt;
&lt;li&gt;All-Pairs Shortest Paths&lt;/li&gt;
&lt;li&gt;Maximum Flow&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Dynamic Programming&lt;/li&gt;
&lt;li&gt;Greedy Algorithms&lt;/li&gt;
&lt;li&gt;Linear Programming&lt;/li&gt;
&lt;li&gt;Sorting Networks&lt;/li&gt;
&lt;li&gt;Matrix Operations&lt;/li&gt;
&lt;li&gt;Polynomials &amp;amp; the FFT&lt;/li&gt;
&lt;li&gt;Number-Theoretic Algorithms&lt;/li&gt;
&lt;li&gt;String Matching&lt;/li&gt;
&lt;li&gt;Computational Geometry&lt;/li&gt;
&lt;li&gt;NP-Completeness&lt;/li&gt;
&lt;li&gt;Approximation Algorithms&lt;/li&gt;
&lt;li&gt;Maps &amp;amp; Hashing&lt;/li&gt;
&lt;li&gt;Tries&lt;/li&gt;
&lt;li&gt;Heaps&lt;/li&gt;
&lt;li&gt;Divide &amp;amp; Conquer&lt;/li&gt;
&lt;li&gt;A*&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>30daysofwriting</category>
      <category>beginners</category>
      <category>computerscience</category>
      <category>career</category>
    </item>
    <item>
      <title>Upgrade your learning + an example study plan for data structures and algorithms</title>
      <dc:creator>Kat  🐆🐾</dc:creator>
      <pubDate>Mon, 18 Nov 2019 20:34:40 +0000</pubDate>
      <link>https://forem.com/codebalance/upgrade-your-learning-an-example-study-plan-for-data-structures-and-algorithms-5he</link>
      <guid>https://forem.com/codebalance/upgrade-your-learning-an-example-study-plan-for-data-structures-and-algorithms-5he</guid>
      <description>&lt;p&gt;Being an engineer means embracing lifelong learning. That's why taking a closer look at your learning methods and taking steps to improve them can help you become a better engineer.&lt;/p&gt;

&lt;p&gt;The following is a summary of techniques that can help you master the material you're studying in a shorter amount of time - taken from the course &lt;a href="https://www.coursera.org/learn/learning-how-to-learn/"&gt;Learning How To Learn&lt;/a&gt; on &lt;a href="https://www.coursera.org/"&gt;Coursera&lt;/a&gt;. I do highly recommend the (free!) course to get a better understanding of the concepts and how they fit together.&lt;/p&gt;

&lt;p&gt;Scroll down to get an example of how to apply those techniques to studying data structures and algorithms.&lt;/p&gt;

&lt;h2&gt;
  
  
  The path from novice to expert
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🙇🏻‍♀️🎮🙇🏻‍♀️🏃🏻‍♀️🙇🏻‍♀️ Understanding material: Alternate between focused &amp;amp; diffuse mode
&lt;/h3&gt;

&lt;p&gt;Switch between focusing on the material you're learning (focused mode) and taking breaks where you focus on something else or where your mind gets to wander around (diffuse mode, e.g. going on a walk/run, cooking, playing, relaxing, taking a nap, etc.)&lt;/p&gt;

&lt;p&gt;❗️Alternating between &lt;a href="https://www.youtube.com/watch?v=lJtUg-3DfUk"&gt;focused mode &amp;amp; diffuse mode thinking&lt;/a&gt; is crucial for understanding difficult material.&lt;br&gt;
❗️You can use the &lt;a href="https://en.wikipedia.org/wiki/Pomodoro_Technique"&gt;Pomodoro technique&lt;/a&gt; to help you alternate between focusing on the material, and taking regular breaks.&lt;/p&gt;

&lt;h3&gt;
  
  
  💾 Remembering material: Commit material into your Long Term Memory (LTM)
&lt;/h3&gt;

&lt;p&gt;Once you understand the material, you have to commit it to your LTM to achieve true mastery.&lt;/p&gt;

&lt;h4&gt;
  
  
  Procrastination
&lt;/h4&gt;

&lt;p&gt;Committing material from your &lt;a href="https://www.youtube.com/watch?v=0egaPpfFFLI"&gt;Short Term Memory (STM) into your Long Term Memory (LTM)&lt;/a&gt; takes time, which is why &lt;a href="https://www.youtube.com/watch?v=bDz7bUor51c"&gt;tackling procrastination&lt;/a&gt; is of the highest priority. Overcome procrastination by focusing on &lt;a href="https://www.youtube.com/watch?v=yS2gCgjSq3U"&gt;process vs. product&lt;/a&gt; (e.g. by using the &lt;a href="https://en.wikipedia.org/wiki/Pomodoro_Technique"&gt;Pomodoro technique&lt;/a&gt;).&lt;/p&gt;

&lt;h4&gt;
  
  
  Methods to commit material into your LTM
&lt;/h4&gt;

&lt;p&gt;❌ Just wanting to learn the material and spending a lot of time with it doesn't guarantee that you'll learn it. &lt;/p&gt;

&lt;p&gt;❗️Avoid the &lt;a href="https://www.youtube.com/watch?v=Pxi6siZeF6w"&gt;illusion of competence&lt;/a&gt; by using the following techniques:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time

&lt;ul&gt;
&lt;li&gt;Be aware that saving something in your LTM will take time. Be patient with yourself.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=hw8kHY9Pfn4"&gt;Deliberate practice&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Deliberately choose to practice what you find most difficult to grasp until it clicks and sticks.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Spaced repetition

&lt;ul&gt;
&lt;li&gt;You need to repeat the material spaced over days and weeks for it to get safely stored in your LTM.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=Pxi6siZeF6w&amp;amp;t=92s"&gt;Recalling&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Avoid the illusion of competence by &lt;em&gt;continuously&lt;/em&gt; testing yourself on the material you're learning.&lt;/li&gt;
&lt;li&gt;Close your book and try to remember what you just learned.&lt;/li&gt;
&lt;li&gt;Practice recalling in various locations to be able to access the material no matter where you are.&lt;/li&gt;
&lt;li&gt;Try to recall the material one more time right before going to bed.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=b2wxhG2viWc"&gt;Sleep&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Does not only make you more beautiful but also flushes out toxins from your brain and strengthens the neural pathways you create when you learn something new.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Tap into your visual memory system &amp;amp; senses

&lt;ul&gt;
&lt;li&gt;Your visual memory system is extremely powerful and can be used to save knowledge in your LTM in a shorter amount of time.&lt;/li&gt;
&lt;li&gt;Make a metaphor/visual image for the concept you're learning.&lt;/li&gt;
&lt;li&gt;Use the &lt;a href="https://en.wikipedia.org/wiki/Method_of_loci"&gt;memory palace technique&lt;/a&gt; to place the image into an imagined space/house/village.&lt;/li&gt;
&lt;li&gt;Try to use your senses to memorize it if possible (vision, smell, touch, hearing, smelling).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔗🎨 Increase your knowledge base &amp;amp; apply it creatively
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Create &lt;a href="https://www.youtube.com/watch?v=PxLHWgQ0cHk"&gt;chunks&lt;/a&gt;:

&lt;ul&gt;
&lt;li&gt;Start small with mini-chunks, little by little. &lt;/li&gt;
&lt;li&gt;Connect the mini-chunks into more complex, bigger chunks through practice &amp;amp; repetition, and by using big-picture thinking.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=J4YazZUXT_A"&gt;Interleaving&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Use interleaving to learn &lt;em&gt;when&lt;/em&gt; you should use a certain technique/concept and to enhance creative thinking.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example Study Plan: Datastructures and Algorithms
&lt;/h2&gt;

&lt;p&gt;❗️At all times: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alternate between focused mode &amp;amp; diffuse mode.&lt;/li&gt;
&lt;li&gt;If you struggle with procrastination, use the Pomodoro technique.&lt;/li&gt;
&lt;li&gt;Make sure you sleep &amp;amp; eat well, and get regular exercise.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. Step:&lt;/strong&gt; Get an understanding of data structures and algorithms by going through a course, reading books, and taking notes. Vary the sources you're learning from to enhance your understanding. Here is a list of courses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/specializations/data-structures-algorithms"&gt;Data Structures and Algorithms Specialization&lt;/a&gt;, University of California San Diego&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/learn/algorithms-part1"&gt;Algorithms, Part 1&lt;/a&gt;, Princeton University&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/learn/algorithms-part2"&gt;Algorithms, Part 2&lt;/a&gt;, Princeton University&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/specializations/algorithms"&gt;Algorithms Specialization&lt;/a&gt;, Stanford University&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.udacity.com/course/data-structures-and-algorithms-nanodegree--nd256"&gt;Data Structures &amp;amp; Algorithms&lt;/a&gt;, Udacity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Step:&lt;/strong&gt; Write index cards from your notes with important facts. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"List all searching algorithms"&lt;/li&gt;
&lt;li&gt;"What's the Dijkstra algorithm"&lt;/li&gt;
&lt;li&gt;"What is the time &amp;amp; space complexity of binary search"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Step:&lt;/strong&gt; Recall &amp;amp; deliberate practice.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use your notes &amp;amp; index cards to test yourself repeatedly, spaced over time, until you remember all the facts.

&lt;ul&gt;
&lt;li&gt;Recall the material one last time before going to bed.&lt;/li&gt;
&lt;li&gt;Recall material at various places, e.g. when commuting, at a cafe, in a different room, etc.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Deliberately practice material that you find difficult to grasp by doing exercises. My preferred way to practice is using the following resources:

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://app.codesignal.com/signup/BCTXJe6pi89ruzqdr/main"&gt;CodeSignal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.crackingthecodinginterview.com/"&gt;Cracking the Coding Interview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Step:&lt;/strong&gt; As you build a library of small chunks of knowledge, take a step back and try to understand the big picture of everything you've learned so far, and how things are connected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👩🏻‍🏫 Repeat Steps 1 - 4 until you are a master in data structures and algorithms.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;Using scientifically proven learning techniques can be tedious and time-costly if you're not used to them. But as you keep practicing and applying these methods to everything you're trying to learn, you'll save a significant amount of time in the long run and will be able to achieve true mastery in your chosen field of study.&lt;/p&gt;

</description>
      <category>todayilearned</category>
      <category>30daysofwriting</category>
      <category>personaldevelopment</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How I overcame my fear of writing</title>
      <dc:creator>Kat  🐆🐾</dc:creator>
      <pubDate>Mon, 18 Nov 2019 01:18:31 +0000</pubDate>
      <link>https://forem.com/codebalance/how-i-overcame-my-fear-of-writing-7gc</link>
      <guid>https://forem.com/codebalance/how-i-overcame-my-fear-of-writing-7gc</guid>
      <description>&lt;p&gt;I am new to blogging. To get into the habit of writing, I set a goal to &lt;a href="https://dev.to/codebalance/30-days-of-writing-3lcg"&gt;write daily for 30 days&lt;/a&gt; - but had to overcome several issues first that kept me from getting started.&lt;/p&gt;

&lt;p&gt;Are you ...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;new to blogging and don't know where to begin?&lt;/li&gt;
&lt;li&gt;scared to put yourself out there? &lt;/li&gt;
&lt;li&gt;worried that you have nothing worthwhile to contribute? &lt;/li&gt;
&lt;li&gt;not sure how to structure your blog posts? &lt;/li&gt;
&lt;li&gt;getting stuck on markdown details? &lt;/li&gt;
&lt;li&gt;wondering how to add emojis to your dev.to posts?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm with you! This is what I've learned, maybe it will resonate with you. If not, please share your own experiences &amp;amp; thoughts in the comments below to help your fellow devs!&lt;/p&gt;

&lt;h2&gt;
  
  
  My obstacles &amp;amp; how I hacked them
&lt;/h2&gt;

&lt;h3&gt;
  
  
  😱 Fear of authenticity &amp;amp; vulnerability
&lt;/h3&gt;

&lt;p&gt;Being authentic and vulnerable is hard, and online shaming is real (thankfully &lt;a href="https://dev.to/code-of-conduct"&gt;not allowed on dev.to&lt;/a&gt;). Sharing your thoughts, experiences, and knowledge online with the entire world means you have to be courageous, vulnerable, and open to criticism.&lt;/p&gt;

&lt;p&gt;My discovery of &lt;a href="https://brenebrown.com/"&gt;Brené Brown&lt;/a&gt; and &lt;a href="https://drgabormate.com/"&gt;Gabor Maté&lt;/a&gt; helped me understand why I struggle with vulnerability and authenticity, and that it's worth to overcome those fears to live wholeheartedly, to tell your story, and connect with people. To get an intro, check out these videos on &lt;a href="https://www.youtube.com/watch?v=iCvmsMzlF7o"&gt;vulnerability&lt;/a&gt; and &lt;a href="https://www.youtube.com/watch?v=l3bynimi8HQ"&gt;authenticity&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Courage starts with showing up and letting ourselves be seen.” - Brené Brown&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  😟 "I have nothing new to contribute"
&lt;/h3&gt;

&lt;p&gt;This kept me from writing my own content for many years - even though I always wanted to! There are plenty of reasons to start blogging. Making a list of your "why" will not only help you overcome self-doubt when you need it most but also give your blog a common thread.&lt;/p&gt;

&lt;p&gt;Here is a list of my reasons to start writing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I love writing - I have journals and handwritten notes everywhere. Maybe going online will help me declutter my home? 😜&lt;/li&gt;
&lt;li&gt;I choose to &lt;a href="https://dev.to/miku86/learn-in-public-4jl2"&gt;learn in public&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Writing helps me to structure and remember what I'm learning.&lt;/li&gt;
&lt;li&gt;I can use my blog posts as a library of my knowledge that I can refer to later on.&lt;/li&gt;
&lt;li&gt;I've been inspired by numerous blog posts written by "ordinary" people, and I am very grateful to have found those. Even though it's not the main reason for me to write, the likelihood of someone getting inspired by what I write is &lt;code&gt;L &amp;gt;= 0&lt;/code&gt;, which is good enough for me 😉&lt;/li&gt;
&lt;li&gt;It helps me practice vulnerability &amp;amp; authenticity.&lt;/li&gt;
&lt;li&gt;Getting the &lt;a href="https://www.businessinsider.com/what-happens-to-your-brain-like-instagram-dopamine-2017-3"&gt;social media dopamine boost&lt;/a&gt; when people like my content is fun and the least damaging when applied to blogging 🤪&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤔 I don't know where to begin
&lt;/h3&gt;

&lt;p&gt;Just write about what you're currently learning, working on, thinking about, dreaming of, creating, contributing to, or wondering about. Simple as that 🙃&lt;/p&gt;

&lt;h3&gt;
  
  
  🗂 How should I structure my blog posts?
&lt;/h3&gt;

&lt;p&gt;A simple structure like this will do:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sfKYnelX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/MCydNIq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sfKYnelX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/MCydNIq.png" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I found &lt;a href="https://www.writerscookbook.com/how-structure-blog-post/"&gt;this article&lt;/a&gt; helpful.&lt;/p&gt;

&lt;p&gt;I enjoy visual blog posts and like to create my own images, GIFs, and visualizations to explore and express my creativity. I do currently use the following tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;iPad Pro + Apple Pencil + &lt;a href="https://tayasui.com/sketches/"&gt;Tayasui Sketches&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://giphy.com/channel/kosekatteunge"&gt;Giphy account&lt;/a&gt; to create &amp;amp; upload my GIFs&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://imgur.com/user/kosekatt"&gt;Imgur account&lt;/a&gt; to upload my images&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🙈 I keep putting it off
&lt;/h3&gt;

&lt;p&gt;I tend to procrastinate when I'm supposed to do something that feels uncomfortable (like writing!). After taking the infamous &lt;a href="https://www.coursera.org/learn/learning-how-to-learn"&gt;"Learning How To Learn"&lt;/a&gt; course on &lt;a href="https://www.coursera.org/"&gt;Coursera&lt;/a&gt;, I've learned that the icky feeling I get when I'm supposed to do something I find difficult is actual pain. Procrastination simply helps to avoid feeling this pain!&lt;/p&gt;

&lt;p&gt;Understanding that helped me be more compassionate and patient with myself. It was also helpful to hear that the pain subsides shortly after you get started on your task and that the &lt;a href="https://en.wikipedia.org/wiki/Pomodoro_Technique"&gt;pomodoro technique 🍅&lt;/a&gt; is a powerful tool to overcome this problem. I like to use &lt;a href="https://apps.apple.com/us/app/be-focused-pro-focus-timer/id961632517?mt=12"&gt;this app on my mac&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  ℹ How to format &amp;amp; spell check your blog post
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet"&gt;Markdown Cheat Sheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/codebalance/how-do-you-pimp-your-blog-post-1blb"&gt;How to add emojis&lt;/a&gt; to dev.to posts&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.grammarly.com/"&gt;Grammarly&lt;/a&gt; if English is not your strongest suit or native language.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Writing is not easy but well worth the effort and time. If you struggle with getting started, you might want to take some time to identify your personal obstacles and find strategies on how to overcome them.&lt;/p&gt;

&lt;p&gt;Share your personal experience with blogging in the comments below!&lt;/p&gt;

</description>
      <category>todayilearned</category>
      <category>30daysofwriting</category>
      <category>beginners</category>
      <category>motivation</category>
    </item>
    <item>
      <title>How do you pimp your blog post?</title>
      <dc:creator>Kat  🐆🐾</dc:creator>
      <pubDate>Sun, 30 Dec 2018 23:12:43 +0000</pubDate>
      <link>https://forem.com/codebalance/how-do-you-pimp-your-blog-post-1blb</link>
      <guid>https://forem.com/codebalance/how-do-you-pimp-your-blog-post-1blb</guid>
      <description>&lt;p&gt;I just wrote my first blog post here at dev.to but found it difficult to pimp it with emojis and highlights. &lt;/p&gt;

&lt;h3&gt;
  
  
  How do you add emojis? What other tips do you have to make articles visually pleasing and interesting?
&lt;/h3&gt;

</description>
      <category>question</category>
      <category>discuss</category>
      <category>tips</category>
      <category>devto</category>
    </item>
    <item>
      <title>#100DaysOfCoding changed my life...</title>
      <dc:creator>Kat  🐆🐾</dc:creator>
      <pubDate>Sun, 30 Dec 2018 22:20:08 +0000</pubDate>
      <link>https://forem.com/codebalance/100daysofcoding-changed-my-life-5hj7</link>
      <guid>https://forem.com/codebalance/100daysofcoding-changed-my-life-5hj7</guid>
      <description>&lt;h2&gt;
  
  
  ... and I'm only on Day [003/100]!
&lt;/h2&gt;

&lt;p&gt;The first time I heard of the &lt;em&gt;#100DaysOfCoding&lt;/em&gt; challenge was in 2014. I read an article about Jennifer Dewald and how she taught herself how to code by making a &lt;a href="https://jenniferdewalt.com/"&gt;website every day for 180 days in a row&lt;/a&gt;. I was incredibly impressed by her accomplishment and doing a challenge like this was on my ToDo list ever since. &lt;/p&gt;

&lt;p&gt;But I wasn't ready... until now. I needed to read another inspiring &lt;a href="https://dev.to/rachelzzhu/my-50daysofcode-challenge-2e13"&gt;blog post&lt;/a&gt; written by &lt;a href="https://dev.to/rachelzzhu"&gt;Rachel&lt;/a&gt; before I decided that it is time to commit to the challenge.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why am I doing it?
&lt;/h1&gt;

&lt;p&gt;I have always admired software developers who would come home after a day at the office, and sit down to work on their side projects. It is obvious that they love coding, are confident in their abilities, and they consider coding as a pastime. These attributes are also what makes them excellent at their job.&lt;/p&gt;

&lt;p&gt;That was never me. I am motivated and excited, I love coding, but when I'm supposed to sit down I doubt myself and end up watching Netflix instead. The reason is that I want to avoid dealing with and overcoming my self-destructive thoughts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Fears and self-doubt&lt;/em&gt;: "I'm not able to do this project. I will fail and once I fail I'll never make it. Better not to start at all to keep my options open!"&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Laziness&lt;/em&gt;: "This is hard work, isn't it? I am tired and deserve to relax."&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Perfectionism&lt;/em&gt;: "If I do this challenge, it has to be perfect. If I don't make impressive progress every day, it does not count. You know you'll fail, so don't even try."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I know this is a wall I built myself, and I can break it down and make the sky my limit!&lt;/p&gt;

&lt;p&gt;(Sidenote: I noticed how these thoughts are similar to those that made me fail at losing weight. Fears would hold me back from even getting started, laziness would keep me in the couch and away from the gym, and perfectionism would lead to black and white thinking which in turn made my weight bounce like a yo-yo until I gave up in exhaustion. Spoiler alert: I cracked this behavior in 2018 and lost successfully 16 pounds and am maintaining my weight with ease 💪)&lt;/p&gt;

&lt;h1&gt;
  
  
  My goals
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Improve my fluency in Python and C++.&lt;/li&gt;
&lt;li&gt;Practice data structures and algorithms.&lt;/li&gt;
&lt;li&gt;Break down the barriers in my head and grow my self-confidence.&lt;/li&gt;
&lt;li&gt;Make it easy to sit down and code, and build the habit to prefer coding over Netflix.&lt;/li&gt;
&lt;li&gt;Implement projects and contribute to open source.&lt;/li&gt;
&lt;li&gt;Get those badges in &lt;a href="https://codesignal.com/"&gt;Codesignal&lt;/a&gt; and green up my Github contribution calendar! 💪&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  My rules
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Code for at least one hour per day.&lt;/li&gt;
&lt;li&gt;Take it easy during the week: work on small coding challenges in &lt;a href="https://codesignal.com/"&gt;Codesignal&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Work on bigger projects and open source contributions on the weekend.&lt;/li&gt;
&lt;li&gt;Summarize what I have learned in a blog post, once a week, written on weekends.&lt;/li&gt;
&lt;li&gt;I can earn a "joker" by coding extra hours. Those will come in handy when I want to go on weekend trips or camping, and I know I won't be able to code on those days.&lt;/li&gt;
&lt;li&gt;Take it slow. Small steps on a daily basis will bring me further than trying too much, too soon, and potentially burning out and giving up. I will get naturally better and faster, and before I know it I'll make big strides on a daily basis.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  What I've learned so far
&lt;/h1&gt;

&lt;p&gt;It has been only three days into the challenge, but I have already learned a lot!&lt;/p&gt;

&lt;p&gt;Every time I finish a new coding task in Codesignal, I look at other peoples solutions and compare their code to mine. That way, I learn different ways of thinking, and more often than not neater ways to implement the solutions. &lt;/p&gt;

&lt;p&gt;So far I've learned about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Differences between Python 2 and Python 3, for example:

&lt;ul&gt;
&lt;li&gt;While &lt;code&gt;/&lt;/code&gt; is an integer-point division in Python 2, it is a floating-point division in Python 3. In order to get an integer division in Python 3 you have to use &lt;code&gt;//&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;You can reverse a list using &lt;a href="https://docs.python.org/release/2.3.5/whatsnew/section-slices.html"&gt;extended slices&lt;/a&gt;, e.g. &lt;code&gt;myList[::-1]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://book.pythontips.com/en/latest/lambdas.html"&gt;Lambdas&lt;/a&gt; are anonymous functions. The syntax to use them is &lt;code&gt;lambda argument: manipulate(argument)&lt;/code&gt;, e.g. &lt;code&gt;add = lambda x, y: x+y&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"&gt;List comprehensions&lt;/a&gt; and &lt;a href="https://docs.python.org/3/tutorial/datastructures.html#dictionaries"&gt;Dict comprehensions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;a href="https://docs.python.org/3/library/functions.html#map"&gt;&lt;code&gt;map&lt;/code&gt;&lt;/a&gt; function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Furthermore, I do already feel more confident in my abilities, and the wall of self-doubt is coming down fast. The time I need to convince myself to sit down and code get progressively smaller, and once I'm at it, I don't want to stop!&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;#100DaysOfCoding&lt;/em&gt; challenge is also the kick-off for me daring to write blog posts (see here, it's my first one!), me giving the world a glimpse to my life through social media (follow me on &lt;a href="https://www.instagram.com/theoriginalcatsy/"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/kathikufieta?lang=en"&gt;Twitter&lt;/a&gt;), and me committing to other &lt;em&gt;#100DaysOfX&lt;/em&gt; challenges such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;#100DaysOfRunning&lt;/em&gt; (Aiming for the NYC marathon 2019! Are you on Strava? Become my friend: &lt;a href="https://www.strava.com/athletes/28880332"&gt;Strava&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;#100DaysOfUnsubscribing&lt;/em&gt; (Gotta clean out my inbox from spam, it's out of control)&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;#100DaysOfMeditation&lt;/em&gt; (I need to improve emotion regulation and concentration. My monkey mind is out of control as well 😛)&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;#100DaysOfStretching&lt;/em&gt; (I'm great at being active but real bad at rehab and stretching, but that's about to change!)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would call that life-changing  🤟&lt;/p&gt;

&lt;h2&gt;
  
  
  Which challenge are you going to commit to?
&lt;/h2&gt;

</description>
      <category>100daysofcoding</category>
      <category>python</category>
      <category>career</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
