add: numbers and strings exercises
This commit is contained in:
@ -8,7 +8,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Do Some Calculations
|
||||||
|
//
|
||||||
// 1. Print the sum of 50 and 25
|
// 1. Print the sum of 50 and 25
|
||||||
// 2. Print the difference of 50 and 15.5
|
// 2. Print the difference of 50 and 15.5
|
||||||
// 3. Print the product of 50 and 0.5
|
// 3. Print the product of 50 and 0.5
|
||||||
@ -26,9 +27,4 @@ package main
|
|||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// ADD YOUR CODE BELOW
|
|
||||||
// USE `fmt.Println` for each question
|
|
||||||
|
|
||||||
// UNCOMMENT IT FIRST, THEN DO NOT TOUCH THIS CODE
|
|
||||||
// fmt.Println(x)
|
|
||||||
}
|
}
|
@ -10,7 +10,8 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Fix the Float
|
||||||
|
//
|
||||||
// Fix the program to print 2.5 instead of 2
|
// Fix the program to print 2.5 instead of 2
|
||||||
//
|
//
|
||||||
// EXPECTED OUTPUT
|
// EXPECTED OUTPUT
|
@ -10,7 +10,8 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Precedence
|
||||||
|
//
|
||||||
// Change the expressions to produce the expected outputs
|
// Change the expressions to produce the expected outputs
|
||||||
//
|
//
|
||||||
// RESTRICTION
|
// RESTRICTION
|
@ -8,7 +8,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Incdecs
|
||||||
|
//
|
||||||
// 1. Increase the `counter` 5 times
|
// 1. Increase the `counter` 5 times
|
||||||
// 2. Decrease the `factor` 2 times
|
// 2. Decrease the `factor` 2 times
|
||||||
// 3. Print the product of counter and factor
|
// 3. Print the product of counter and factor
|
@ -10,7 +10,8 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Manipulate a Counter
|
||||||
|
//
|
||||||
// 1. Write the simplest line of code to increase
|
// 1. Write the simplest line of code to increase
|
||||||
// the counter variable by 1.
|
// the counter variable by 1.
|
||||||
//
|
//
|
@ -10,7 +10,8 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Simplify the Assignments
|
||||||
|
//
|
||||||
// Simplify the code (refactor)
|
// Simplify the code (refactor)
|
||||||
//
|
//
|
||||||
// RESTRICTION
|
// RESTRICTION
|
@ -12,7 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Circle Area
|
||||||
|
//
|
||||||
// Calculate the area of a circle from the given radius
|
// Calculate the area of a circle from the given radius
|
||||||
//
|
//
|
||||||
// CIRCLE AREA FORMULA
|
// CIRCLE AREA FORMULA
|
@ -12,7 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Sphere Area
|
||||||
|
//
|
||||||
// 1. Get the radius from the command-line
|
// 1. Get the radius from the command-line
|
||||||
// 2. Convert it to a float64
|
// 2. Convert it to a float64
|
||||||
// 3. Calculate the surface area of a sphere
|
// 3. Calculate the surface area of a sphere
|
@ -12,7 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Sphere Volume
|
||||||
|
//
|
||||||
// 1. Get the radius from the command-line
|
// 1. Get the radius from the command-line
|
||||||
// 2. Convert it to a float64
|
// 2. Convert it to a float64
|
||||||
// 3. Calculate the volume of a sphere
|
// 3. Calculate the volume of a sphere
|
19
08-numbers-and-strings/01-numbers/exercises/README.md
Normal file
19
08-numbers-and-strings/01-numbers/exercises/README.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Numbers, Precedence, and Assignment Operations
|
||||||
|
|
||||||
|
1. **[Do Some Calculations](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/01-numbers/exercises/01-do-some-calculations)**
|
||||||
|
|
||||||
|
2. **[Fix the Float](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/01-numbers/exercises/02-fix-the-float)**
|
||||||
|
|
||||||
|
3. **[Precedence](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/01-numbers/exercises/03-precedence)**
|
||||||
|
|
||||||
|
4. **[IncDecs](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/01-numbers/exercises/04-incdecs)**
|
||||||
|
|
||||||
|
5. **[Manipulate a Counter](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/01-numbers/exercises/05-manipulate-a-counter)**
|
||||||
|
|
||||||
|
6. **[Simplify the Assignments](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/01-numbers/exercises/06-simplify-the-assignments)**
|
||||||
|
|
||||||
|
7. **[Circle Area](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/01-numbers/exercises/07-circle-area)**
|
||||||
|
|
||||||
|
8. **[Sphere Area](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/01-numbers/exercises/08-sphere-area)**
|
||||||
|
|
||||||
|
9. **[Sphere Volume](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/01-numbers/exercises/09-sphere-volume)**
|
18
08-numbers-and-strings/02-strings/README.md
Normal file
18
08-numbers-and-strings/02-strings/README.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Basic Strings
|
||||||
|
|
||||||
|
1. **[Windows Path](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/02-strings/exercises/01-windows-path)**
|
||||||
|
|
||||||
|
2. **[Print JSON](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/02-strings/exercises/02-print-json)**
|
||||||
|
|
||||||
|
3. **[Raw Concat](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/02-strings/exercises/03-raw-concat)**
|
||||||
|
|
||||||
|
4. **[Count the Chars](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/02-strings/exercises/04-count-the-chars)**
|
||||||
|
|
||||||
|
5. **[Improved Banger](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/02-strings/exercises/05-improved-banger)**
|
||||||
|
|
||||||
|
6. **[ToLowercase](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/02-strings/exercises/06-tolowercase)**
|
||||||
|
|
||||||
|
7. **[Trim It](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/02-strings/exercises/07-trim-it)**
|
||||||
|
|
||||||
|
8. **[Right Trim It](https://github.com/inancgumus/learngo/tree/master/08-numbers-and-strings/02-strings/exercises/08-right-trim-it)**
|
||||||
|
|
@ -10,7 +10,8 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Windows Path
|
||||||
|
//
|
||||||
// 1. Change the following program
|
// 1. Change the following program
|
||||||
// 2. It should use a raw string literal instead
|
// 2. It should use a raw string literal instead
|
||||||
//
|
//
|
@ -10,7 +10,8 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Print JSON
|
||||||
|
//
|
||||||
// 1. Change the following program
|
// 1. Change the following program
|
||||||
// 2. It should use a raw string literal instead
|
// 2. It should use a raw string literal instead
|
||||||
//
|
//
|
@ -10,7 +10,8 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Raw Concat
|
||||||
|
//
|
||||||
// 1. Initialize the name variable
|
// 1. Initialize the name variable
|
||||||
// by getting input from the command line
|
// by getting input from the command line
|
||||||
//
|
//
|
@ -13,7 +13,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Count the Chars
|
||||||
|
//
|
||||||
// 1. Change the following program to work with unicode
|
// 1. Change the following program to work with unicode
|
||||||
// characters.
|
// characters.
|
||||||
//
|
//
|
@ -14,7 +14,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Improved Banger
|
||||||
|
//
|
||||||
// Change the Banger program the work with Unicode
|
// Change the Banger program the work with Unicode
|
||||||
// characters.
|
// characters.
|
||||||
//
|
//
|
@ -8,12 +8,17 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: ToLowercase
|
||||||
|
//
|
||||||
// 1. Look at the documentation of strings package
|
// 1. Look at the documentation of strings package
|
||||||
// 2. Find a function that changes the letters into lowercase
|
// 2. Find a function that changes the letters into lowercase
|
||||||
// 3. Get a value from the command-line
|
// 3. Get a value from the command-line
|
||||||
// 4. Print the given value in lowercase letters
|
// 4. Print the given value in lowercase letters
|
||||||
//
|
//
|
||||||
|
// HINT
|
||||||
|
// Check out the strings package from Go online documentation.
|
||||||
|
// You will find the lowercase function there.
|
||||||
|
//
|
||||||
// INPUT
|
// INPUT
|
||||||
// "SHEPARD"
|
// "SHEPARD"
|
||||||
//
|
//
|
@ -12,7 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Trim It
|
||||||
|
//
|
||||||
// 1. Look at the documentation of strings package
|
// 1. Look at the documentation of strings package
|
||||||
// 2. Find a function that trims the spaces from
|
// 2. Find a function that trims the spaces from
|
||||||
// the given string
|
// the given string
|
@ -12,7 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE
|
// EXERCISE: Right Trim It
|
||||||
|
//
|
||||||
// 1. Look at the documentation of strings package
|
// 1. Look at the documentation of strings package
|
||||||
// 2. Find a function that trims the spaces from
|
// 2. Find a function that trims the spaces from
|
||||||
// only the right-most part of the given string
|
// only the right-most part of the given string
|
Reference in New Issue
Block a user