refactor: 6th section first two lectures exercises and questions

This commit is contained in:
Inanc Gumus
2018-10-22 22:00:34 +03:00
parent 2e650b9a1e
commit 411be187ab
33 changed files with 114 additions and 49 deletions

View File

@ -8,12 +8,18 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Print the literals
// 1- Print a few integer literals //
// 2- Print a few float literals // 1. Print a few integer literals
// 3- Print true and false bool literals //
// 4- Print your name using a string literal // 2. Print a few float literals
// 5- Print a non-english sentence using a string literal //
// 3. Print true and false bool literals
//
// 4. Print your name using a string literal
//
// 5. Print a non-english sentence using a string literal
//
// --------------------------------------------------------- // ---------------------------------------------------------
func main() { func main() {

View File

@ -12,18 +12,19 @@ import "fmt"
// THIS EXERCISE IS OPTIONAL // THIS EXERCISE IS OPTIONAL
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Print hexes
// 1- Print 0 to 9 in hexadecimal
// 2- Print 10 to 15 in hexadecimal
// 3- Print 17 in hexadecimal
// 4- Print 25 in hexadecimal
// 5- Print 50 in hexadecimal
// 6- Print 100 in hexadecimal
// //
// NOTES // 1. Print 0 to 9 in hexadecimal
// https://stackoverflow.com/questions/910309/how-to-turn-hexadecimal-into-decimal-using-brain
// //
// https://simple.wikipedia.org/wiki/Hexadecimal_numeral_system // 2. Print 10 to 15 in hexadecimal
//
// 3. Print 17 in hexadecimal
//
// 4. Print 25 in hexadecimal
//
// 5. Print 50 in hexadecimal
//
// 6. Print 100 in hexadecimal
// //
// EXPECTED OUTPUT // EXPECTED OUTPUT
// 0 1 2 3 4 5 6 7 8 9 // 0 1 2 3 4 5 6 7 8 9
@ -32,6 +33,12 @@ import "fmt"
// 25 // 25
// 50 // 50
// 100 // 100
//
// NOTES
// https://stackoverflow.com/questions/910309/how-to-turn-hexadecimal-into-decimal-using-brain
//
// https://simple.wikipedia.org/wiki/Hexadecimal_numeral_system
//
// --------------------------------------------------------- // ---------------------------------------------------------
func main() { func main() {

View File

@ -0,0 +1,7 @@
1. **[Print the literals](https://github.com/inancgumus/learngo/tree/master/06-variables/01-basic-data-types/exercises/01-print-the-literals)**
Print a few values using the literals
2. **[Print hexes](https://github.com/inancgumus/learngo/tree/master/06-variables/01-basic-data-types/exercises/02-print-hexes)** (optional exercise)
Print numbers in hexadecimals

View File

@ -8,9 +8,11 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Declare int
// 1- Declare and print a variable with a float64 type //
// 2- The declared variable's name should be: brightness // 1. Declare and print a variable with an int type
//
// 2. The declared variable's name should be: height
// //
// EXPECTED OUTPUT // EXPECTED OUTPUT
// 0 // 0

View File

@ -8,9 +8,11 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// OPTIONAL EXERCISE // EXERCISE: Declare bool
// 1- Declare and print a bool variable //
// 2- The variable's name should be: isOn // 1. Declare and print a bool variable
//
// 2. The variable's name should be: isOn
// //
// EXPECTED OUTPUT // EXPECTED OUTPUT
// false // false

View File

@ -8,9 +8,11 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Declare float64
// 1- Declare and print a variable with an int type //
// 2- The declared variable's name should be: height // 1. Declare and print a variable with a float64 type
//
// 2. The declared variable's name should be: brightness
// //
// EXPECTED OUTPUT // EXPECTED OUTPUT
// 0 // 0

View File

@ -8,9 +8,11 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Declare string
// 1- Declare a string variable //
// 2- Print that variable // 1. Declare a string variable
//
// 2. Print that variable
// //
// EXPECTED OUTPUT // EXPECTED OUTPUT
// "" // ""

View File

@ -8,8 +8,9 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Undeclarables
// 1- Declare the variables below: //
// 1. Declare the variables below:
// 3speed // 3speed
// !speed // !speed
// spe?ed // spe?ed
@ -17,10 +18,10 @@ package main
// func // func
// package // package
// //
// 2- Observe the error messages // 2. Observe the error messages
// //
// NOTE // NOTE
// The types of the variables are not important. // The types of the variables are not important.
// --------------------------------------------------------- // ---------------------------------------------------------
func main() { func main() {

View File

@ -8,8 +8,9 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Declare with bits
// 1- Declare a few variables using the following types //
// 1. Declare a few variables using the following types
// int // int
// int8 // int8
// int16 // int16
@ -24,8 +25,9 @@ package main
// rune // rune
// byte // byte
// //
// 2- Observe their output // 2. Observe their output
// 3- After you've done, check out the solution //
// 3. After you've done, check out the solution
// and read the comments there // and read the comments there
// //
// EXPECTED OUTPUT // EXPECTED OUTPUT

View File

@ -8,7 +8,8 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Multiple
//
// 1. Declare two variables using // 1. Declare two variables using
// multiple variable declaration statement // multiple variable declaration statement
// //

View File

@ -8,7 +8,8 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Multiple #2
//
// 1. Declare and initialize two string variables // 1. Declare and initialize two string variables
// using multiple variable declaration // using multiple variable declaration
// //

View File

@ -8,10 +8,13 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Unused
// 1- Declare a variable //
// 2- Variable's name should be: isLiquid // 1. Declare a variable
// 3- Discard it using a blank-identifier //
// 2. Variable's name should be: isLiquid
//
// 3. Discard it using a blank-identifier
// //
// NOTE // NOTE
// Do not print the variable // Do not print the variable

View File

@ -8,10 +8,11 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Package Variable
// 1- Declare a variable in the package-scope
// //
// 2- Observe whether something happens when you don't // 1. Declare a variable in the package-scope
//
// 2. Observe whether something happens when you don't
// use it // use it
// --------------------------------------------------------- // ---------------------------------------------------------

View File

@ -8,11 +8,14 @@
package main package main
// --------------------------------------------------------- // ---------------------------------------------------------
// EXERCISE // EXERCISE: Wrong doer
// 1- Print a variable //
// 2- Then declare it // 1. Print a variable
//
// 2. Then declare it
// (This means: Try to print it before its declaration) // (This means: Try to print it before its declaration)
// 3- Observe the error //
// 3. Observe the error
// --------------------------------------------------------- // ---------------------------------------------------------
func main() { func main() {

View File

@ -0,0 +1,25 @@
# Declare and Print Variables
Warm up. Declare a few variables and get some experience. Get used to the variable declaration syntax.
1. **[Declare int](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/01-int)**
2. **[Declare bool](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/02-bool)**
3. **[Declare float64](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/03-float64)**
4. **[Declare string](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/04-string)**
5. **[Declare undeclarables](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/05-undeclarables)**
6. **[Declare with bits](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/06-with-bits)**
7. **[Declare multiple](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/07-multiple)**
8. **[Declare multiple 2](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/08-multiple-2)**
9. **[Declare an unused variable](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/09-unused)**
10. **[Declare a package variable](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/10-package-variable)**
11. **[Use before declare](https://github.com/inancgumus/learngo/tree/master/06-variables/02-declarations/exercises/11-wrong-doer)**