# 1. 輸出

## I. 註解

> 用於對程式碼進行說明，被視為註解的文字不會被電腦所執行(不影響執行)

### **A. 單行註解**

> 利用 `#` 來做單行註解

```python
# print('Make Me Great Again')
# ლ(´ڡ`ლ)ლ(´ڡ`ლ)ლ(´ڡ`ლ)
# 太神奇了傑克
# こんにちは
```

### **B. 多行註解**

> 利用一對 `'''` 或 `"""` 做多行註解

```python
"""
你像窩在被子裡的舒服
卻又像風 捉摸不住
像手腕上散發的香水味
像愛不釋手的 紅色高跟鞋
"""

'''
人類如果沒有心臟　那就好了
受傷不會流血
悲傷也不會流淚
'''
```

### C. **註解快捷鍵**

`Ctrl` + `/` 【再點擊取消註解】

## II. 印出一行字串

> * `print` 後要加上一對小括號
> * 小括號中的**雙引號**或**單引號**表示要印出的字串

```python
print("當傷痛是一種選擇的時候，其實是一種幸福")
```

```python
print('One day you will realize that what is more important than making lots of friends is cherishing the ones that are real.')
```

* **全形半形切換**： `ａｎｙｔｉｍｅ`(全形) `anytime`(半形)【一般為半形】，按`shift` + `空白建` 即可切換【程式語言的世界裡，都用半形文字與符號】
* **插入**： `Insert` 鍵按了之後打的字會吃掉後面的字，再按一次即可恢復
* 複製的快捷鍵：`Ctrl` + `c`
* 貼上的快捷鍵：`Ctrl` + `v`
* 剪下的快捷鍵：`Ctrl` + `x`
* 還原的快捷鍵：`Ctrl` + `z`
* 全選的快捷鍵：`Ctrl` + `a`
* 存檔的快捷鍵：`Ctrl` + `s`

## III. 印出多行字串

**方法一**：用多個 `print`

```python
print("菸一支一支一支的點 酒一杯一杯一杯的乾")
print('請你要體諒我 我酒量不好賣給我衝康 (。´艸`。)')
```

**方法二**：用 `'''` 或 `"""`

```python
print('''一段感情之所以會失敗，
往往是因為你愛上的不是他，
而是你心目中的那個他''')
```

## IV. 一行內印出多個字串

```python
print("天竺鼠車車", 'PUI PUI', '515151')
```

> 這種方式，會印出由空格隔開的形式

## V. 印出四則運算結果

> 四則運算後的結果會是數字型態

```python
print(3) # 3
print(3+3) # 6
print(3-3) # 0
print(3*3) # 9
print(3/2) # 1.5 直接會變為浮點數
print(3%3) # 0 取餘數部分
print(3**3) # 27 指數
print(3//3) # 1 取商數部分
```

## VI. 字串與數字的搭配

觀察下方幾種不同寫法的結果

```python
print('3'+'3') # 33
print('3', '3') # 3 3
print('3', 3) # 3 3
print('3+3') # 3+3
print('3'*3) # 333
print(3*3) # 9
```

下方為常見的應用錯誤

```python
print('3' 3) # 兩者間沒有符號做連結
print('3' + 3) # 將加號用於字串與數字
print('3' * '3') # 將/,%,-,//,...用於兩字串間
```

## VII. 跳脫字元

有些符號為**跳脫字元**，必須要在前面加上一個`\`才顯示得出來唷!

```python
print("\\") # \
print("\'") # '
print("\"") # "
```

### A. 常用功能型跳脫字元

`\n`：換列

`\b`：退格

```python
print('人生最困難的不是面對各種挫折打擊\n，而是面臨各種挫折困難，仍沒有失去對人世的熱情')
print('人生最困難的不是面對各種挫折打擊\b，而是面臨各種挫折困難，仍沒有失去對人世的熱情')
```

### B. `print` 隱藏的換列字元

`print` 內建`\n`，因此執行完會換一行

```python
# 嘗試執行下方程式碼
print('人之初')
print('')
print('性本善')
print()
print("性相近")
```

若不希望換行可以用下列作法

```python
print('人生沒有不能回頭的路', end="")
print("有時你只是忘了還可以轉身")
```

```python
print('人生沒有不能回頭的路', end="，")
print("有時你只是忘了還可以轉身")
```

## VIII. 學習單

{% embed url="<https://docs.google.com/presentation/d/e/2PACX-1vSsZJ-wpVhQEIqu92Z54sSeOEVQBCZZZrwKrpraZS4vlquqcnCUE2T-8wUXN7BTWPr-aqORhMvcOZDU/embed?start=false&loop=false&delayms=30000>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://simplife.gitbook.io/python/xin-shou-cun/shu-chu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
