FAQ: Learn Go: Functions - Review

This community-built FAQ covers the “Review” exercise from the lesson “Learn Go: Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

FAQs on the exercise Review

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like () to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi there.
I try to create a function for calculating square area and perimeter both.

func square(a int) (int, int) {
sq := a * a
per := 4 * a
return sq, per
}

But, it is not working. Can anybody help?

Hi there @akutsenko, welcome to the forums!

What exactly isn’t working? What is the expected result?
What happens when you call your function?

I rewriting a function as:

func square(a int) (int, int) {
var sq, per int
sq = a * a
per = 4 * a
return sq, per
}

And ran it:

func main() {
fmt.Println(“Our square area and perimetr is:”, square(13))
}

I’ll make a mistake: multiple-value square() in single-value context

If i calling this functions just:

func main() {
fmt.Println(square(13))
}

Everything is ok!

1 Like

i found this fix:

``````func main() {
a, b := square(13)
fmt.Println(“Our square area and perimetr is:”, a, b)
}
``````