Golang exercises for beginner programmers. If you are looking for a Go challenge and are a beginner programmer, this might be for you. These exercises will help you with Go training.
You can download the answers here: Download answers
- Create a program that shows your name
- Create a program that shows your address
- Create a program and add a comment with your name
- Create a program with multiple string variables
- Create a program that holds your name in a string.
- Make a program that lets the user input a name
- Get a number from the console and check if it’s between 1 and 10.
- Calculate the year given the date of birth and age
- Create a program that calculates the average weight of 5 people.
- What’s the difference between a local and global variable?
- How can you make a global variable?
- Create an array with the number 0 to 10
- Create an array of strings with names
- Can for loops exist inside for loops?
- Make a program that counts from 1 to 10.
- What is the purpose of
- What the difference between the line
for index, element := range aand the line
for _, element := range a?
- Make a program that divides x by 2 if it’s greater than 0
- Find out if if-statements can be used inside if-statements.
- How does a while loop differ from a for loop?
- Check if a file exists on your local disk
- Can you check if a file exists on an external disk?
- Think of when you’d read a file ‘line by line’ vs ‘at once’?
- Create a new file containing names and read it into an array
- Write a list of cities to a new file.
- Which package has the rename function?
- Create a struct house with variables noRooms, price and city
- How does a struct differ from a class?
- What is a map?
- Is a map ordered?
- What can you use a map for?
- Make a program that rolls a dice (1 to 6)
- Can you generate negative numbers?
- Where are variables stored in the computer?
- What is a pointer?
- How can you declare a pointer?
- Take the string ‘hello world’ and slice it in two.
- Can you take a slice of a slice?
- Create a method that sums two numbers
- Create a method that calls another method.
- Predict what this code does:
- Change the return values from 2,4 to “hello”,”world”. Does it still work?
- Can a combination of strings and numbers be used?
- Create a variadic function that prints the names of students
- When is a function recursive?
- Can a recursive function call non-recursive functions?
- What is a goroutine?
- How can you turn a function into a goroutine?
- What is concurrency?
- When do you need channels?
- How can you send data into a channel?
- How can you read data from a channel?