Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
LEARN GOLANG QUICKLY AND PYTHON CODING PRACTICE EXERCISES CODING FOR BEGINNERS WITH HANDS ON PROJECTS BY J J TAM
Page
3
Introduction Go Language Go: Hello World Application Go language: Build executable Go: Primitive Data Types Go language: Print value and type of a variable Go language: Initialize multiple variables in one line Go Language: Constants Go language: iota identifier Go Language: Type Conversion Go language: Type Inference Go language: strings Go language: concatenate strings Go language: multi line strings Go Language: Arrays Go Language: Arrays are passed by value Go language: Slices Go language: Slices are passed by reference Go language: Iterate over a slice using range keyword Go language: Get slice from a slice Go language: Append an element to a slice Go Language: Map data structure Go language: Define map using literal notation Go language: len : Get number of items in a map Go Language: Map: Check whether an item exists in map or not
Page
4
Go language: Delete item from the map Go language: Print all the keys of map Go language: Print key, value from map Go language: if statement Go language: if-else statement Go language: if statement: combine initialisation and condition evaluation in same line Go Language: switch statement Go language: switch without an expression Go Language: for loop Go Language: Use for loop as while loop Go language: Print elements of array Go language: Iterate over a map Go language: Read data from console or user Go Language: Create a function Go Language: Pass by Reference Go language: Variadic Functions Go language: Return a value from function Go language: Anonymous functions Go Language: Functions continued Go Language: return Error from a function Go Language: Structs Go Language: Construct an object to a structure using & Go language : struct literal notation Go language: constructor functions
Page
5
Go Language: Adding Methods to a struct PYTHON String – Exercises Python: Reverse a string Remove a newline in Python Find the common values Python Data Type: List – Exercises Python: Sum all the items in a list Get the largest number from a list Remove duplicates from a list Python Data Types: Dictionary – Exercises Add a key to a dictionary Iterate over dictionaries using for loops Merge two Python dictionaries Multiply all the items in a dictionary Remove a key from a dictionary Get a dictionary from an object's fields Combine two dictionary adding values for common keys Find the highest 3 values PYTHON BASICS – EXERCISES Display current date and time Print the calendar Computes the value of n+nn+nnn Calculate number of days volume of a sphere in Python
Page
6
Compute the area of Triangle Compute the GCD CALCULATE THE LCM Convert feet and inches to centimeters Convert time – seconds Convert seconds to day Program to solve Future value of amount Check whether a file exists Convert the distance Sum all the items Multiplies all the items Get the largest number Get the smallest number Remove duplicates Clone or copy a list Difference between the two lists Generate all permutations Find the second smallest Get unique values Get the frequency of the elements Generate all sublists Find common items Create a list
Page
7
LEARN GOLANG QUICKLY CODING FOR BEGINNERS WITH HANDS ON PROJECTS BY J J TAM
Page
8
Introduction Go Language Go is an open source language to build reliable software in efficient way. a . Go is a compiled language. b . Go has clean and clear syntax c . Go has in built language support for concurrency d . Go is statically typed language e . Functions are first class citizens in Go f . Go initialize default values for uninitialized variables. For example, for the string default value is empty string. g . Go has good features that makes the development fast h . Go has only few keywords to remember i . Most of the computers now a days has multiple cores, but not all languages have efficient ways to utilize these multi cores. But Go has very good support to utilize multi core system in efficient way. . Since Go has very good built-in support for concurrency features, you no need to depend on any threading libraries to develop concurrent applications. k . Go has in-built garbage collector, so you no need to take the overhead of managing application memory. j. In Go, complex types are composed of smaller types. Go encourages composition.
Page
9
Install and setup Go Download latest version of Go from below location. https://golang.org/ Extract the downloaded zip file, you can see below content structure. $ ls AUTHORS CONTRIBUTORS PATENTS VERSION bin favicon.ico misc robots.txt test CONTRIBUTING.md LICENSE README.md api doc lib pkg src Add bin directory path to your system path. Open terminal or command prompt and execute the command ‘go’, you can see below output in console. $ go Go is a tool for managing Go source code. Usage: go <command> [arguments] The commands are: bug start a bug report build compile packages and dependencies clean remove object files and cached files doc show documentation for package or symbol
Page
10
env print Go environment information fix update packages to use new APIs fmt gofmt (reformat) package sources generate generate Go files by processing source get download and install packages and dependencies install compile and install packages and dependencies list list packages or modules mod module maintenance run compile and run Go program test test packages tool run specified go tool version print Go version vet report likely mistakes in packages Use "go help <command>" for more information about a command. Additional help topics: buildmode build modes c calling between Go and C cache build and test caching environment environment variables filetype file types go.mod the go.mod file gopath GOPATH environment variable gopath-get legacy GOPATH go get goproxy module proxy protocol importpath import path syntax modules modules, module versions, and more module-get module-aware go get packages package lists and patterns testflag testing flags testfunc testing functions Use "go help <topic>" for more information about that topic.
Page
11
Note If you do not want to install Go in your system, you can play around Go at ‘https://play.golang.org/’.
Page
12
Go: Hello World Application Open any text editor and create HelloWorld.go file with below content. HelloWorld.go package main func main() { println ( "Hello, World" ) } Execute the command ‘go run HelloWorld.go’. $ go run HelloWorld.go Hello, World package main It is used by the Go compiler to determine application entry point. func main() Program execution starts from here. ‘func’ keyword is used to define a function. ‘main’ function do not take any arguments. println("Hello, World") ‘println’ is a built in function in Go, that is used to print given message to console. Note a . Unlike C, C++ and Java, you no need to end a statement by a semi colon. b . String in Go, are placed in between double quotes
Page
13
c . Strings in Go are Unicode.
Page
14
Go language: Build executable Use the command ‘go build goFilePath’, to build the executable from go program. App.go package main import "fmt" func main() { fmt.Println( "Hello World" ) } $ go build App.go $ $ ls App App.go As you see 'App' file is created after building. If you run build command in windows, it generates App.exe file. Run the file 'App' to see the output. $ ./App Hello World
Page
15
Go: Primitive Data Types Below table summarizes the data types provided by Go Language. Integer Data Types Data Type Description Minimum Value Maximum Value uint8 Unsigned 8- bit integers 0 255 uint16 Unsigned 16-bit integers 0 65535 uint32 Unsigned 32-bit integers 0 4294967295 uint64 Unsigned 64-bit integers 0 18446744073709551615 int8 Signed 8-bit integers -128 127 int16 Signed 16- bit integers -32768 32767 int32 Signed 32- bit integers -2147483648 2147483647 int64 Signed 64- bit integers -9223372036854775808 9223372036854775807 Below table summarizes floating point numbers. Data Type Description float32 IEEE-754 32-bit floating-point numbers float64 IEEE-754 64-bit floating-point numbers
Page
16
Below table summarizes the complex numbers. Data Type Description complex64 Complex numbers with float32 real and imaginary parts complex128 Complex numbers with float64 real and imaginary parts Apart from the above types, Go language support below types that are implementation specific. a . Byte b . rune (same as int32) c . uint d . int e . uintptr Syntax to create variable var variableName dataType var variableName dataType = value variableName := value HelloWorld.go package main import "fmt" func main() { var a int = 10 var b uint8 = 11 var c uint16 = 12 var d uint32 = 13 var e uint64 = 14 var f int8 = 15 var g int16 = 16
Page
17
var h int32 = 17 var i int64 = 18 var k float32 = 2 var l float64 = 2 complex1 := complex ( 10 , 13 ) fmt.Println( "a : " , a); fmt.Println( "b : " , b); fmt.Println( "c : " , c); fmt.Println( "d : " , d); fmt.Println( "e : " , e); fmt.Println( "f : " , f); fmt.Println( "g : " , g); fmt.Println( "h : " , h); fmt.Println( "i : " , i); fmt.Println( "k : " , k); fmt.Println( "l : " , l); fmt.Println( "complex1 : " , complex1); } Output a : 10 b : 11 c : 12 d : 13 e : 14 f : 15 g : 16 h : 17 i : 18 k : 2 l : 2 complex1 : (10+13i) How to access real and imaginary numbers from complex numbers?
Page
18
You can use ‘real’ and ‘img’ methods to access the real and complex parts of a number. myComplex := complex(10, 13) real(myComplex) imag(myComplex) HelloWorld.go package main import "fmt" func main() { complex1 := complex ( 10 , 13 ) var realPart = real (complex1) var imgPart = imag (complex1) fmt.Println( "complex1 : " , complex1); fmt.Println( "realPart : " , realPart); fmt.Println( "imgPart : " , imgPart); } Output complex1 : (10+13i) realPart : 10 imgPart : 13
Page
19
Go language: Print value and type of a variable %v is used to print the value of a variable %T is used to print the type of a variable. App.go package main import "fmt" func main() { var x int = 10 fmt.Printf( "i : %v, type : %T\n" , x, x) } Output i : 10, type : int Go language: Initialize multiple variables in one line If variables are of same data type, you can initialize them in one line like below. var i, j, k int = 1, 2, 3
Page
20
App.go package main import ( "fmt" ) func main() { var i, j, k int = 1 , 2 , 3 fmt.Println( "i : " , i, ", j : " , j, ", k : " , k) } Output i : 1 , j : 2 , k : 3
The above is a preview of the first 20 pages. Register to read the complete e-book.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
【One-Line Pitch】
A hands-on starter kit that teaches Go through short annotated snippets and then drills Python fundamentals via bite-sized exercises. Best for absolute beginners who learn by typing and running code rather than reading theory.
【Book Arc】
- **Opening (~0%–9%)**: Environment setup and first contact — installing Go, running a Hello World, and meeting primitive types, complex numbers, and the `iota` constant pattern. Solves the "how do I even start" barrier.
- **Early (~9%–27%)**: Core data handling — strings, concatenation, fixed-size arrays, and the crucial value-vs-reference distinction that trips up newcomers from other languages.
- **Middle (~27%–64%)**: The working core of Go — slices with `make`/`append`, maps (create, read, delete, iterate), control flow (`if` with inline init, `switch`, the single `for` loop), and the beginnings of functions including variadics and multiple returns.
- **Late (~64%–82%)**: Functions in depth (anonymous functions, error returns) and structs — heap vs stack creation, `&` and `new`, struct literals, constructor functions, and methods with receiver syntax.
- **Ending (~82%–100%)**: A pivot to Python practice exercises — list and dictionary manipulation, string operations, math problems (LCM, sphere volume, digit patterns), and small file/OS checks. The excerpts do not show a bridging chapter between the Go and Python halves.
【Key Takeaways】
- **Go's type system is explicit and sized** (Opening): the book tabulates every integer width and float variant, so you learn to pick types deliberately rather than by habit.
- **Arrays copy, slices share** (Early–Middle): this is the single most important mental model in the Go half — passing an array to a function leaves the original untouched, while a slice mutates the underlying data.
- **Maps are the workhorse collection** (Middle): creation, `len`, `delete`, and `range` iteration are all demonstrated with runnable output, including the gotcha that a missing key returns a zero value silently.
- **Go has exactly one loop** (Middle): the `for` keyword covers counting loops, while-style loops, and `range` iteration — a deliberate simplification worth internalizing early.
- **Functions are first-class and multi-valued** (Middle–Late): variadics, anonymous functions, and returning `(result, error)` pairs together form Go's idiomatic error-handling style.
- **Structs separate data from behavior** (Late): methods attached via receivers keep structs clean, and the book contrasts stack vs heap creation with `new` and `&`.
- **Python exercises reinforce the same fundamentals from a different angle** (Ending): list min/max/sum, dictionary key removal, `nlargest`, and string intersection show how the same problems look in a dynamically typed language.
【Reading Tips】
- **Type every snippet.** This is a cookbook, not a narrative — the value comes from running the code and seeing the printed output, especially for slice-vs-array behavior.
- **Deep-read the slices and maps sections (Middle).** These carry the most conceptual weight; skim the primitive-type tables if you already know another typed language.
- **Watch for the language switch around 82%.** The Python half is a separate exercise set with no transition — treat it as a second, independent workbook.
- **Use the exercises as self-tests.** Cover the solution, attempt the problem, then compare — the Python section is structured for exactly this.
- **Don't expect project-scale examples.** Despite the "hands-on projects" framing, the excerpts show isolated snippets rather than integrated applications.
【Coverage Limits】
This guide covers the full arc visible in the excerpts: Go fundamentals through structs and methods, then Python practice exercises. The excerpts do not cover any capstone project, concurrency, interfaces, or the transition between the two languages, so those may exist in the book but are not represented here.
Passage locations
Excerpt 1
书名: LEARN GOLANG QUICKLY AND PYTHON CODING PRACTICE EXERCISES Coding For Beginners (TAM, JJ) (Z-Library) 作者: TAM, JJ Go language: Delete item from the map Go...
View in text
Page 20
"fmt" ) func main() { var i, j, k int = 1 , 2 , 3 fmt.Println( "i : " , i, ", j : " , j, ", k : " , k) } Output i : 1 , j : 2 , k : 3 Go languag...
View in text
Excerpt 3
n takes three arguments type, length and capacity. Syntax make([]Type, length, capacity) make([]Type, length) []Type{} []Type{value1, value2, ..., valueN}...
View in text
Excerpt 4
a is 10") } Above statements can be written like below. if a := 10; a == 10 { fmt.Println("Value of a is 10") } HelloWorld.go package main i...
View in text
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later
Tip the Site
Scan the WeChat Pay or Alipay code to tip. No login required.
WeChat Pay
Alipay