Below you will find pages that utilize the taxonomy term “learn to code”
November 3, 2024
Learn to Code In 5 Minutes A Day: Lesson 10
Lesson 9 Solution: Refactoring Yesterday’s exercise was to see if you could figure out a way to refactor our code so far. In other words, we wanted to see if we could simplify this code:
func roman(number int) string { if number == 3 { return "III" } if number == 2 { return "II" } return "I" } The way we do this is with a loop. A loop lets us repeat things over and over and is one of the fundamental tools of programming.
read more
June 10, 2024
Learn to Code in 5 Minutes a Day: Lesson 9
Lesson 8 Solution: Roman Numeral III Yesterday’s exercise was to get to roman numeral III. Did you get something like this?
roman.go
func roman(number int) string { if number == 3 { return "III" } if number == 2 { return "II" } return "I" } roman_test.go
package main import ( "testing" ) func TestRoman1(t *testing.T) { result := roman(1) expected := "I" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.
read more
June 8, 2024
Learn to Code in 5 Minutes a Day: Lesson 8
Lesson 7 Solution: Roman Numeral II If you completed lesson 7, you should have gotten something like the following. Remember, there is no one correct way to program any more than there is one right way to write a story or paint a picture. If you came up with a slightly different solution but it passes your unit tests, awesome!!!
roman_test.go
func TestRoman1(t *testing.T) { result := roman(1) expected := "I" if result !
read more
June 7, 2024
Learn to Code in 5 Minutes a Day: Lesson 7
Lesson 6 Solution: Roman Numeral I You should have come up with a solution that looks like the following. If you did, great! All it took was changing:
return ""
to
return “I”
roman.go
func roman(number int) string { return "I" } roman_test.go
func TestRoman(t *testing.T) { result := roman(1) expected := "I" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.", result, expected) } } go test PASS ok hello 0.
read more
June 6, 2024
Learn to Code in 5 Minutes a Day: Lesson 6
Recap of progress to date So far you’ve learned some basics of writing code. We haven’t talked about terms, but you’ve learned how to compile and format code, how to create functions, how to define variables, how to unit test, and how to do conditional statements (aka if statements). Even more importantly, you’ve learned how to search for answers and experiment. You’ve got a lot of the building blocks for coding.
read more
June 3, 2024
Learn to Code in 5 Minutes a Day: Lesson 5
Session 4 Solution: hello_test.go
func TestHelloInigoMontoya(t *testing.T) { result := hello("inigo montoya") expected := "hello, inigo montoya" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.", result, expected) } } func TestHelloDuaLipa(t *testing.T) { result := hello("Dua Lipa") expected := "hello, Dua Lipa" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.", result, expected) } } func TestHelloDarthVader(t *testing.T) { result := hello("Darth Vader") expected := "hello, Darth Vader" if result !
read more
May 14, 2024
Learn to Code in 5 Minutes a Day: Lesson 4
My experience with ADHD has been that slow consistent progress is how I achieve lasting results. When I hyperfocus on a new interest, I tend to burn out after a month or two and never touch it again. So this course is an attempt to go back and document how I wished someone had taught me to program. It literally took me years of trying before I felt comfortable programming professionally.
read more
May 13, 2024
Learn to Code in 5 Minutes a Day: Lesson 3
Yesterday’s solution: package main import "fmt" func main() { fmt.Println("hello world") } When you run it you should be able to see it work like this:
go run hello, world If you weren’t able to get this going on your own, go back until you can create this from memory and understand the pieces.
Hint: you may have to run a command like this if you’re getting errors about go.mod:
read more
May 12, 2024
Learn to Code In 5 Minutes a Day: Lesson 2
Lesson 2: Write Your First Program, aka Hello, World So yesterday we learned how to install golang.
If you haven’t done that yet, go do that.
Goals Today: write your first go program. build the habit of spending 5 minutes a day learning. Let’s get started: In this course I’m going to spend most of my time giving high level directions and trust your ADHD will take you down rabbit holes as you get curious about things.
read more
May 12, 2024
Learn to Code in 5 Minutes a Day: Lesson 1
Lesson 1: Set up General rules for this course:
Commit to at least 5 minutes a day. Figuring things out on your own is better than being given the answers. The general idea is, instead of spending hours following along typing what you see on a YouTube video and then realizing you retain none of it, each lesson will be a small programming puzzle to solve that gets you along the way to being a programmer.
read more