---
# System prepended metadata

title: 3/28筆記

---

3/28筆記
===

畫圖套件
---
**scatter**:畫出散點圖
**axis**:呈現出正方形方格
**xlim**:設置x軸範圍
**ylim**:設置y軸範圍

```python=
#使用畫圖套件 matplotlib.pyplot
import matplotlib.pyplot as plt
a=[1,2,3,4,5]
b=[1,2,3,4,5]

plt.scatter(x=a,y=b,s=5)
plt.axis('square')
plt.xlim(0,10)
plt.ylim(0,10)

print(f'我的圖形')

plt.show()
```
![](https://i.imgur.com/zXiUpjW.png)


字典
---

### 走訪字典
```
for x in dict:
  print(x)
走訪所有鍵
```

```python=
dict={"apple": 40, "banana" :60, "cherry" :80, "mango":20, "pineapple":50, "papaya": 90}
forx in dict:
print (x)
```
![](https://i.imgur.com/TmxozjH.png)

```
for x in dict.values():
  print(x)
走訪所有值
```
```python=
dict={"apple": 40, "banana":60, "cherry":80, "mango":20, "pineapple":50, "papaya": 90}
for x in dict.values():
print(x)
```
![](https://i.imgur.com/P01SoNq.png)

```
for x,y in dict.items():
  print(x,y)
走訪所有配對
```
```python=
dict={"apple": 40, "banana": 60, "cherry": 80,"mango": 20,"pineapple": 50,"papava" : 90}
for x,y in  dict.items ():
  print(x,y)
```
![](https://i.imgur.com/A8wkS1o.png)

字串
---
**字串切片&擷取字元**
![](https://i.imgur.com/Af7hZY9.png)
**求字串長度**
![](https://i.imgur.com/A1t2NNu.png)

作業
---
#### 第一題： 求”麥禮仁“的學號
![](https://i.imgur.com/NotNqaI.png)

#### 第二題：求所有姓陳的同學的學號姓名
![](https://i.imgur.com/Bx8xyRe.png)
#### 第三題：求全班同學有哪幾個姓氏&同學姓名是否有重複
![](https://i.imgur.com/eKPXeCd.png)
#### 第四題：歡迎{a}同學參加我們的營隊活動
![](https://i.imgur.com/7BUdOdE.png)
