Initial commit

This commit is contained in:
Inanc Gumus
2018-10-13 23:30:21 +03:00
commit cde4e6632c
567 changed files with 17896 additions and 0 deletions

View File

@ -0,0 +1,95 @@
## Which group of operators below is arithmetic operators?
1. **, /, ^, !, ++, --
2. *, /, %, +, - *CORRECT*
3. &, |, +, -, /
## Which value below you can use with a remainder operator?
1. 3.54
2. true
3. 57 *CORRECT*
4. "Try Me!"
> 4. Nice Try. But, that's not right. Sorry.
> 3. That's right. The remainder operator only works on integer values.
## What's the result of this expression?
```go
8 % 3
```
1. 4
2. 2
3. 0
4. 1 *CORRECT*
## What's the result of this expression?
```go
-(3 * -2)
```
1. -6
2. -1
3. 0
4. 6 *CORRECT*
## What's the result of this expression?
```go
var degree float64 = 10 / 4
```
1. 2.5
2. 2.49
3. 2 *CORRECT*
4. 0
> 3. That's right. An integer value cannot contain fractional parts.
## What's the result of this expression?
```go
var degree float64 = 3. / 2
```
1. 1.5 *CORRECT*
2. 1.49
3. 1
4. 0
> 1. That's right. `3.` makes the whole expression a float value.
## What's the type of the `x` variable?
```go
x := 5 * 2.
```
1. int
2. float64 *CORRECT*
3. bool
4. string
> 1. Look closely to 2 there.
> 2. Why? Because, `2.` there makes the expressions a float value. Cool.
> 3. Oh, come on! Life is not always true and false.
> 4. I can't see any double-quotes or back-quotes, can you?
## What's the type of the `x` variable?
```go
x := 5 * -(2)
```
1. int *CORRECT*
2. float64
3. bool
4. string
> 1. Why? Because, there only integer numbers.
> 2. I can't see any fractional parts there, can you?
> 3. Oh, come on! Life is not always true and false.
> 4. I can't see any double-quotes or back-quotes, can you?
## Which kind of values can result in inaccurate calculations?
1. integers
2. floats *CORRECT*
3. bools
4. strings

View File

@ -0,0 +1,44 @@
## What's the result of the expression?
```go
5 - 2 * 5 + 7
```
1. 2 *CORRECT*
2. 22
3. -19
4. 36
5. -12
## What's the result of the expression?
```go
5 - (2 * 5) + 7
```
1. 2
2. 22 *CORRECT*
3. -19
4. 36
5. -12
## What's the result of the expression?
```go
5 - 2 * (5 + 7)
```
1. 2
2. 22
3. -19 *CORRECT*
4. 36
5. -12
## What's the result of the expression?
```go
5. -(2 * 5 + 7)
```
1. 2
2. 22
3. -19
4. -12
5. -12.0 *CORRECT*
> 4. You're close but remember! The result of an expression with floats and integers is always a float.

View File

@ -0,0 +1,98 @@
## Which expression increases `n` by 1?
```go
var n float64
```
1. `n = +1`
2. `n = n++`
3. `n = n + 1` *CORRECT*
4. `++n`
> 1. This just assigns 1 to n.
> 2. IncDec statement can't be used as an operator.
> 4. Go doesn't support prefix incdec notation.
## Which expression decreases `n` by 1?
```go
var n int
```
1. `n = -1`
2. `n = n--`
3. `n = n - 1` *CORRECT*
4. `--n`
> 1. This just assigns -1 to n.
> 2. IncDec statement can't be used as an operator.
> 4. Go doesn't support prefix incdec notation.
## Which code below equals to `n = n + 1`?
1. `n++` *CORRECT*
2. `n = n++`
3. `++n`
4. `n = n ++ 1`
> 2. IncDec statement can't be used as an operator.
> 3. Go doesn't support prefix incdec notation.
> 4. What's that? ++?
## Which code below equals to `n = n + 1`?
1. `n = n++`
2. `n += 1` *CORRECT*
3. `++n`
4. `n = n ++ 1`
> 1. IncDec statement can't be used as an operator.
> 3. Go doesn't support prefix incdec notation.
> 4. What's that? ++?
## Which code below equals to `n -= 1`?
1. `n = n--`
2. `n += 1--`
3. `n--` *CORRECT*
4. `--n`
> 1. IncDec statement can't be used as an operator.
> 2. IncDec statement can't be used as an operator. And also, you can't use it with `1--`. The value should be addressable. You're going to learn what that means soon.
> 4. Go doesn't support prefix incdec notation.
## Which code below divides the `length` by 10?
1. `length = length // 10`
2. `length /= 10` *CORRECT*
3. `length //= 10`
> 1. What's that? `//`?
> 2. That's right. This equals to: `length = length / 10`
> 3. What's that? `//=`?
## Which code below equals to `x = x % 2`?
1. `x = x / 2`
2. `x =% x`
3. `x %= x` *CORRECT*
> 1. This is a division. You need to use the remainder operator.
> 2. Close... But, the `%` operator is on the wrong side of the assignment.
## Which function below converts a string value into a float value?
1. `fmtconv.ToFloat`
2. `conv.ParseFloat`
3. `strconv.ParseFloat` *CORRECT*
4. `strconv.ToFloat`
## Which code is correct?
If you don't remember it, this its function signature:
```go
func ParseFloat(s string, bitSize int) (float64, error)
```
1. `strconv.ParseFloat("10", 128)`
2. `strconv.ParseFloat("10", 64)` *CORRECT*
3. `strconv.ParseFloat("10", "64")`
4. `strconv.ParseFloat(10, 64)`
> 1. There are no 128-bit floating point values in Go (Actually there are, but they only belong to the compile-time).