Introduction
This lab aims to test your understanding of Golang's basic value types, including strings, integers, floats, and booleans.
This is a Guided Lab, which provides step-by-step instructions to help you learn and practice. Follow the instructions carefully to complete each step and gain hands-on experience. Historical data shows that this is a intermediate level lab with a 74% completion rate. It has received a 100% positive review rate from learners.
Value Types
Your task is to complete the calculate function that takes in two integers and returns their sum and product.
- The
calculatefunction should take in two integers as parameters. - The
calculatefunction should return two integers, the sum and product of the input parameters.
$ go run values.go
golang
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false
There is the full code below:
// Go has various value types including strings,
// integers, floats, booleans, etc. Here are a few
// basic examples.
package main
import "fmt"
func main() {
// Strings, which can be added together with `+`.
fmt.Println("go" + "lang")
// Integers and floats.
fmt.Println("1+1 =", 1+1)
fmt.Println("7.0/3.0 =", 7.0/3.0)
// Booleans, with boolean operators as you'd expect.
fmt.Println(true && false)
fmt.Println(true || false)
fmt.Println(!true)
}
Summary
In this lab, you were tasked with completing the calculate function to calculate the sum and product of two integers. By doing so, you were able to demonstrate your understanding of Golang's basic value types.