---
title: 0805 內部課程
tags: 內部研習
---
<style>
.navbar-brand:after {
content: " × Web:AI";
}
</style>
> [程式上傳區](https://hackmd.io/@webduino/0805_stu)
>
## 講義
👉 [python 語法-1](https://www.canva.com/design/DAEmI26MV6U/BsmO6Vo7w2KHlacwFu-BlQ/view)
### 題目 1
```python
# 利用 print( ) 函式介紹一下你自己吧 !!
```
### 題目 2
```python
# 請建立一個變數 number,
# 並用 = 等號儲存文字 "1234" 做為密碼,
# 用 print() 顯示含有密碼的文字:
# 我的密碼是 1234
```
### 資料型態
```python
a = 123
b = 1.23
c = "123"
d = True
print(type(a)) # <class 'int'>
print(type(b)) # <class 'float'>
print(type(c)) # <class 'str'>
print(type(d)) # <class 'bool'>
```
### 簡易計算機
```python
print(1234 + 1234) # 2468
print(5678 - 1234) # 4444
print(1234 * 1234) # 1522756
print(123 / 4) # 30.75
print(123 % 4) # 3
print(2**3) # 8
```
### 題目 3
```python
# 90位的學生要進行分成6小隊,而每一個小隊會再分成 3 組,請問每一隊會有幾位學生 ? 每一組會有幾位學生 ? 輸出如下:
# 每一隊有 xxx 位學生,每一組有 xxx 位學生
```
### 邏輯運算子
```python
x = 10
y = 5
print(x > y) # True
print(x >= y) # True
print(x < y) # False
print(x <= y) # False
print(x == y) # False
print(x != y) # True
```
### 空格數
```python
text = "a"
if text=="a":
print("apple")
if text=="a":
print("banana")
if text=="a":
print("cat")
if text=="a":
print("dog")
```
### 判斷式 -1
```python
score = 70
if score >= 60:
print("及格")
```
### 判斷式 -2
```python
status = '有疫苗了'
if status == '有疫苗了':
print('我就要趕快去預約')
else:
print('又要被關在家裡了啦')
```
### 題目 4
```python
# 幫我寫一個程式來判斷是否成年
# 如果大於 18 歲則顯示成年
# 否則顯示未成年
```
### 判斷式 -3
```python
PH = 9
if PH == 7:
print("中性")
elif PH < 7:
print("鹼性")
else:
print("酸性")
```
### 題目 5
```python
# 請你設計一個程式,當使用者輸入身高(cm)、體重(kg)後,計算出BMI,並依據下表顯示健康狀況。
# BMI = 體重/(身高**2) 體重:公斤 身高:公尺
# 健康狀況判斷
# 過輕 BMI < 18.5
# 正常 18.5 <= BMI < 23
# 過重 23 <= BMI
```
### 題目 6
```python
# 設一個變數 n ,自訂輸入範圍,並依序從 0 顯示到 n
```
### 題目 7
```python
# 利用 for 迴圈顯示 -55 到 195 中,個位數為 5 的數
```
### 題目 8:九九乘法表 -1
```python
# 設定一個變數 n ,並顯示出 n 乘上 1 ~ 9 的值
# 2
# 4
# ...
# 18
```
### 題目 9:九九乘法表 -2
```python
# 承上題,判斷 n 是否為 1 ~ 9 中的值,如果輸入錯誤請回覆 wrong,否則顯示如下
# 2 x 1 = 2
# 2 x 2 = 4
# ...
# 2 x 9 = 18
```
### 題目 10:九九乘法表 -3
```python
# 承上題,將乘法表完整,並在每個不同被乘數中用線分行 (like: '— — —')
```
### 題目 11
```python
# 計算 100 以內的奇數總和
```
### 建立集合
```python
fruit = ["apple", "banana", "grapes", "lemon", "mango", "orange"]
print(fruit)
```
### 修改集合元素
```python
fruit[1] = "watermelon"
print(fruit)
```
### 插入集合元素
```python
fruit.append("strawberries")
print(fruit)
```
### 移除集合元素
```python
fruit.remove("grapes")
print(fruit)
```
### 整理集合
```python
fruit.sort()
print(fruit)
```
### 題目 12:建立集合
``` python
# 假如你是火鍋店老闆,發現店裡面沒有菜單,請幫我將它完成
```
:::info
carrot 胡蘿蔔 corn 玉米
spinach 菠菜 mushroom 香菇
lobster 龍蝦 scallops 干貝
taro 芋頭 cauliflower 花椰菜
:::
### 題目 13:移除集合元素
```python
# 因為颱風來襲,我們菠菜大幅漲價,所以決定將這個項目移除
```
### 題目 14:插入集合元素
```python
# 最近店長想要新增甜點來吸引客人,請幫我新增 padding (布丁)進去
```
### 題目 15:修改集合元素
```python
# 今天生意太好,布丁一下子就銷售一空,改賣鬆餅,請幫我修改一下菜單
```
### 題目 16:整理集合
```python
# 就差最後一部了,幫我將菜單按照字母排序,辛苦了
```
### 索取第一筆元素
```python
fruit = ["apple" , "banana", "grapes" , "lemon" , "mango" , "orange"]
print(fruit[0])
```
### 索取最後一筆元素
```python
fruit = ["apple" , "banana", "grapes" , "lemon" , "mango" , "orange"]
print(fruit[-1])
```
### 索取某範圍元素
```python
fruit = ["apple" , "banana", "grapes" , "lemon" , "mango" , "orange"]
print(fruit[2:5])
```