learngo/08-numbers-and-strings/01-numbers/questions/01-arithmetic-operators.md

96 lines
1.6 KiB
Markdown
Raw Normal View History

2018-10-13 23:30:21 +03:00
## 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