---
# System prepended metadata

title: Python 基本功

---

# Python 基本功

### 1.文字輸出
``` python=
a = 33      #整數型態
b = 6.8     #浮點數
c = "abc"   #文字串型態,前後要加雙引號
d = '123'   #文字串型態,加單引號亦可
print("Hello")  #直接印出文字串
print(a)
print(a + b)
print(c + d)
print("A","B", "C", "D")
print("A", "B", "C", "D", sep = "")
print("A", "B", "C", "D", sep = "|")
```
![](https://i.imgur.com/xCXulB4.png)

那如果想要文字加數字一起輸出勒?


### 2.數學運算

``` python=
a = 11
b = 3.8
print(a + b)
print(a - b)
print(b * 2)
print(b / 2)
print(a << 1)
print(a >> 1)
print(a % 3)
print(a // 3)
print(a ** 2)
``` 
![](https://i.imgur.com/gdzkMRz.png)



### 3.輸入內容
``` python=
a = input("Input a = ")
b = input("Input b = ")
print(a)
print(b)
print(a + b)

```
面積計算機
![](https://i.imgur.com/LszlWn6.png)


### 4.載入常數

``` python=
import math

a = input("Input a = ")
b = input("Input b = ")
print(a)
print(b)
print(a + b)

print(math.pi)
```
想想看
如何輸入"角度"轉成"弧度"?
如何輸入"弧度"轉成"角度"?