Skip to content

Commit 8a91998

Browse files
author
黯星座 Nova
authored
Add: 06-variables Chinese version (#127)
1 parent 6c0b298 commit 8a91998

File tree

133 files changed

+3826
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+3826
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright © 2018 Inanc Gumus
2+
// Learn Go Programming Course
3+
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
4+
//
5+
// For more tutorials : https://learngoprogramming.com
6+
// In-person training : https://www.linkedin.com/in/inancgumus/
7+
// Follow me on twitter: https://twitter.com/inancgumus
8+
9+
package main
10+
11+
import "fmt"
12+
13+
func main() {
14+
// 整数型
15+
fmt.Println(
16+
-200, -100, 0, 50, 100, 100,
17+
)
18+
19+
// 浮点型
20+
fmt.Println(
21+
-50.5, -20.5, -0., 1., 100.56, // ...
22+
)
23+
24+
// 布尔值
25+
fmt.Println(
26+
true, false,
27+
)
28+
29+
// 字符串 - utf-8
30+
fmt.Println(
31+
"", // 空字符串, 只打印一个空格
32+
"hi",
33+
34+
// unicode
35+
"nasılsın?", // 土耳其语的 "你好吗"
36+
"hi there 星!", // "你好,star!"
37+
)
38+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright © 2018 Inanc Gumus
2+
// Learn Go Programming Course
3+
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
4+
//
5+
// For more tutorials : https://learngoprogramming.com
6+
// In-person training : https://www.linkedin.com/in/inancgumus/
7+
// Follow me on twitter: https://twitter.com/inancgumus
8+
9+
package main
10+
11+
// ---------------------------------------------------------
12+
// 练习: 打印字面量
13+
//
14+
// 1. 打印一些整数型
15+
//
16+
// 2. 打印一些浮点型
17+
//
18+
// 3. 打印 true 和 false 的布尔值
19+
//
20+
// 4. 用字符串打印你的名字
21+
//
22+
// 5. 用字符串打印一句非英文的句子
23+
//
24+
// ---------------------------------------------------------
25+
26+
func main() {
27+
// 使用 fmt.Println()
28+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright © 2018 Inanc Gumus
2+
// Learn Go Programming Course
3+
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
4+
//
5+
// For more tutorials : https://learngoprogramming.com
6+
// In-person training : https://www.linkedin.com/in/inancgumus/
7+
// Follow me on twitter: https://twitter.com/inancgumus
8+
9+
package main
10+
11+
import "fmt"
12+
13+
func main() {
14+
fmt.Println(42, 8500, 344433, -2323)
15+
fmt.Println(3.14, 6.28, -42.)
16+
fmt.Println(true, false)
17+
fmt.Println("Hi! I'm Inanc!")
18+
fmt.Println("Merhaba, adım İnanç!")
19+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright © 2018 Inanc Gumus
2+
// Learn Go Programming Course
3+
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
4+
//
5+
// For more tutorials : https://learngoprogramming.com
6+
// In-person training : https://www.linkedin.com/in/inancgumus/
7+
// Follow me on twitter: https://twitter.com/inancgumus
8+
9+
package main
10+
11+
import "fmt"
12+
13+
// 这个练习是可选的
14+
15+
// ---------------------------------------------------------
16+
// 练习: 打印十六进制
17+
//
18+
// 1. 打印十六进制的 0 到 9
19+
//
20+
// 2. 打印十六进制的 10 到 15
21+
//
22+
// 3. 打印十六进制的 17
23+
//
24+
// 4. 打印十六进制的 25
25+
//
26+
// 5. P打印十六进制的 50
27+
//
28+
// 6. 打印十六进制的 100
29+
//
30+
// 期望输出
31+
// 0 1 2 3 4 5 6 7 8 9
32+
// 10 11 12 13 14 15
33+
// 17
34+
// 25
35+
// 50
36+
// 100
37+
//
38+
// NOTE
39+
// https://stackoverflow.com/questions/910309/how-to-turn-hexadecimal-into-decimal-using-brain
40+
//
41+
// https://simple.wikipedia.org/wiki/Hexadecimal_numeral_system
42+
//
43+
// ---------------------------------------------------------
44+
45+
func main() {
46+
// 例子
47+
48+
// 我要打印十六进制的 10
49+
fmt.Println(0xa)
50+
51+
// 我要打印十六进制的 16
52+
// 0x10
53+
// ^^----- 1 * 0 = 0
54+
// |
55+
// +------ 16 * 1 = 16
56+
// = 16
57+
fmt.Println(0x10)
58+
59+
// 我要打印十六进制的 150
60+
// 0x96
61+
// ^^----- 1 * 6 = 6
62+
// |
63+
// +------ 16 * 9 = 144
64+
// = 150
65+
fmt.Println(0x96)
66+
67+
// 把上面的所有代码注释掉, 然后
68+
// 在下面写下你的代码
69+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright © 2018 Inanc Gumus
2+
// Learn Go Programming Course
3+
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
4+
//
5+
// For more tutorials : https://learngoprogramming.com
6+
// In-person training : https://www.linkedin.com/in/inancgumus/
7+
// Follow me on twitter: https://twitter.com/inancgumus
8+
9+
package main
10+
11+
import "fmt"
12+
13+
func main() {
14+
fmt.Println(0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9)
15+
fmt.Println(0xa, 0xb, 0xc, 0xd, 0xe, 0xf)
16+
fmt.Println(0x11) // 17
17+
fmt.Println(0x19) // 25
18+
fmt.Println(0x32) // 50
19+
fmt.Println(0x64) // 100
20+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
1. **[打印字面量](https://github.com/inancgumus/learngo/tree/master/translation/chinese/06-变量/01-基础数据类型/练习/01-print-the-literals)**
2+
3+
使用字面量打印一些值
4+
5+
2. **[打印十六进制数](https://github.com/inancgumus/learngo/tree/master/translation/chinese/06-变量/01-基础数据类型/练习/02-print-hexes)** (可选练习)
6+
7+
打印十六进制的数
8+
9+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## 下面哪个是整数型 (int)?
2+
3+
* -42 *正确*
4+
* 这是整数型
5+
* "Hello"
6+
* 这是字符串
7+
* false
8+
* 这是布尔值
9+
* 3.14
10+
* 这是浮点型
11+
12+
## 下面哪个是浮点型 (float)?
13+
14+
* -42
15+
* "Hello"
16+
* false
17+
* 3.14 *正确*
18+
19+
## 下面哪个是浮点型 (float)?
20+
21+
* 6,28
22+
* ,28
23+
* .28 *正确*
24+
* 628
25+
26+
## 下面哪个是字符串 (string)?
27+
28+
* -42
29+
* "Hello" *正确*
30+
* false
31+
* 3.14
32+
33+
## 下面哪个是布尔值 (bool)?
34+
35+
* -42
36+
* "Hello"
37+
* false *正确*
38+
* 3.14
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright © 2018 Inanc Gumus
2+
// Learn Go Programming Course
3+
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
4+
//
5+
// For more tutorials : https://learngoprogramming.com
6+
// In-person training : https://www.linkedin.com/in/inancgumus/
7+
// Follow me on twitter: https://twitter.com/inancgumus
8+
9+
package main
10+
11+
import "fmt"
12+
13+
func main() {
14+
var speed int
15+
16+
fmt.Println(speed)
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright © 2018 Inanc Gumus
2+
// Learn Go Programming Course
3+
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
4+
//
5+
// For more tutorials : https://learngoprogramming.com
6+
// In-person training : https://www.linkedin.com/in/inancgumus/
7+
// Follow me on twitter: https://twitter.com/inancgumus
8+
9+
package main
10+
11+
// 变量声明规则
12+
13+
func main() {
14+
// 正确的声明
15+
var speed int
16+
var SpeeD int
17+
18+
// 下划线开头是允许但不推荐的
19+
var _speed int
20+
21+
// Unicode 字母是允许的
22+
var 速度 int
23+
24+
// 让编译器开心
25+
_, _, _, _ = speed, SpeeD, _speed, 速度
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright © 2018 Inanc Gumus
2+
// Learn Go Programming Course
3+
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
4+
//
5+
// For more tutorials : https://learngoprogramming.com
6+
// In-person training : https://www.linkedin.com/in/inancgumus/
7+
// Follow me on twitter: https://twitter.com/inancgumus
8+
9+
package main
10+
11+
func main() {
12+
// fmt.Println(speed)
13+
// var speed int
14+
}

0 commit comments

Comments
 (0)