Skip to content

Commit

Permalink
Add: 06-variables Chinese version (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
黯星座 Nova authored Oct 17, 2022
1 parent 6c0b298 commit 8a91998
Show file tree
Hide file tree
Showing 133 changed files with 3,826 additions and 0 deletions.
38 changes: 38 additions & 0 deletions translation/chinese/06-变量/01-基础数据类型/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
// 整数型
fmt.Println(
-200, -100, 0, 50, 100, 100,
)

// 浮点型
fmt.Println(
-50.5, -20.5, -0., 1., 100.56, // ...
)

// 布尔值
fmt.Println(
true, false,
)

// 字符串 - utf-8
fmt.Println(
"", // 空字符串, 只打印一个空格
"hi",

// unicode
"nasılsın?", // 土耳其语的 "你好吗"
"hi there 星!", // "你好,star!"
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

// ---------------------------------------------------------
// 练习: 打印字面量
//
// 1. 打印一些整数型
//
// 2. 打印一些浮点型
//
// 3. 打印 true 和 false 的布尔值
//
// 4. 用字符串打印你的名字
//
// 5. 用字符串打印一句非英文的句子
//
// ---------------------------------------------------------

func main() {
// 使用 fmt.Println()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
fmt.Println(42, 8500, 344433, -2323)
fmt.Println(3.14, 6.28, -42.)
fmt.Println(true, false)
fmt.Println("Hi! I'm Inanc!")
fmt.Println("Merhaba, adım İnanç!")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

// 这个练习是可选的

// ---------------------------------------------------------
// 练习: 打印十六进制
//
// 1. 打印十六进制的 0 到 9
//
// 2. 打印十六进制的 10 到 15
//
// 3. 打印十六进制的 17
//
// 4. 打印十六进制的 25
//
// 5. P打印十六进制的 50
//
// 6. 打印十六进制的 100
//
// 期望输出
// 0 1 2 3 4 5 6 7 8 9
// 10 11 12 13 14 15
// 17
// 25
// 50
// 100
//
// NOTE
// https://stackoverflow.com/questions/910309/how-to-turn-hexadecimal-into-decimal-using-brain
//
// https://simple.wikipedia.org/wiki/Hexadecimal_numeral_system
//
// ---------------------------------------------------------

func main() {
// 例子

// 我要打印十六进制的 10
fmt.Println(0xa)

// 我要打印十六进制的 16
// 0x10
// ^^----- 1 * 0 = 0
// |
// +------ 16 * 1 = 16
// = 16
fmt.Println(0x10)

// 我要打印十六进制的 150
// 0x96
// ^^----- 1 * 6 = 6
// |
// +------ 16 * 9 = 144
// = 150
fmt.Println(0x96)

// 把上面的所有代码注释掉, 然后
// 在下面写下你的代码
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
fmt.Println(0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9)
fmt.Println(0xa, 0xb, 0xc, 0xd, 0xe, 0xf)
fmt.Println(0x11) // 17
fmt.Println(0x19) // 25
fmt.Println(0x32) // 50
fmt.Println(0x64) // 100
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1. **[打印字面量](https://github.com/inancgumus/learngo/tree/master/translation/chinese/06-变量/01-基础数据类型/练习/01-print-the-literals)**

使用字面量打印一些值

2. **[打印十六进制数](https://github.com/inancgumus/learngo/tree/master/translation/chinese/06-变量/01-基础数据类型/练习/02-print-hexes)** (可选练习)

打印十六进制的数


Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## 下面哪个是整数型 (int)?

* -42 *正确*
* 这是整数型
* "Hello"
* 这是字符串
* false
* 这是布尔值
* 3.14
* 这是浮点型

## 下面哪个是浮点型 (float)?

* -42
* "Hello"
* false
* 3.14 *正确*

## 下面哪个是浮点型 (float)?

* 6,28
* ,28
* .28 *正确*
* 628

## 下面哪个是字符串 (string)?

* -42
* "Hello" *正确*
* false
* 3.14

## 下面哪个是布尔值 (bool)?

* -42
* "Hello"
* false *正确*
* 3.14
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
var speed int

fmt.Println(speed)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

// 变量声明规则

func main() {
// 正确的声明
var speed int
var SpeeD int

// 下划线开头是允许但不推荐的
var _speed int

// Unicode 字母是允许的
var 速度 int

// 让编译器开心
_, _, _, _ = speed, SpeeD, _speed, 速度
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

func main() {
// fmt.Println(speed)
// var speed int
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
var nFiles int
var counter int
var nCPU int

fmt.Println(
nFiles,
counter,
nCPU,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
var heat float64
var ratio float64
var degree float64

fmt.Println(
heat,
ratio,
degree,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
var off bool
var valid bool
var closed bool

fmt.Println(
off,
valid,
closed,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
var msg string
var name string
var text string

fmt.Println(
msg,
name,
text,
)
}
Loading

0 comments on commit 8a91998

Please sign in to comment.