---
# System prepended metadata

title: "\U0001F308專三Python"
tags: [school]

---

###### tags: `school`
# 🌈專三Python
![](https://i.imgur.com/WeUGmd2.png)
## 🐪第二章(1)2022/3/8
![](https://i.imgur.com/Iaa8m29.png)
![](https://i.imgur.com/MlR87uV.png)
![](https://i.imgur.com/CWcevGi.png)
![](https://i.imgur.com/cIAjp5T.png)

## 🐪第二章(2)2022/3/15
![](https://i.imgur.com/CB23yjX.png)
![](https://i.imgur.com/Klyb44J.png)
![](https://i.imgur.com/M0niC61.png)
![](https://i.imgur.com/RQf1Hhc.png)
![](https://i.imgur.com/3fvOkm4.png)
![](https://i.imgur.com/d7KqBfn.png)
![](https://i.imgur.com/TZ80EHP.png)
![](https://i.imgur.com/bVWaXM6.png)
![](https://i.imgur.com/CMhcc7B.png)

## 🐪第三章(1) 2022/4/12
![](https://i.imgur.com/UOF9Qhe.png)
![](https://i.imgur.com/jXMjBBA.png)
![](https://i.imgur.com/nay5CIL.png)
![](https://i.imgur.com/9ukfSmp.png)
![](https://i.imgur.com/lx8jeyK.png)
![](https://i.imgur.com/EpxUEnz.png)

## 🐪第三章(2) 2022/4/26
![](https://i.imgur.com/tuuNY9T.png)
![](https://i.imgur.com/NmrLOvl.png)
![](https://i.imgur.com/oLZ7sHh.png)
![](https://i.imgur.com/iFOWTkd.png)
![](https://i.imgur.com/OvK4yjk.png)

## 🐪第三章(3 :tuple) 2022/5/3

![](https://i.imgur.com/BeTspfa.png)
![](https://i.imgur.com/5xMqglx.png)
![](https://i.imgur.com/tv0xJPk.png)
![](https://i.imgur.com/5LhzKhb.png)
![](https://i.imgur.com/Ghyj8Nv.png)
![](https://i.imgur.com/MfvW5Q2.png)

## 🐪第四章(1) 2022/3/22
![](https://i.imgur.com/UDQ47TD.png)
![](https://i.imgur.com/rbEcOXh.png)
![](https://i.imgur.com/JJWp2TT.png)
![](https://i.imgur.com/9eLm4ui.png)
![](https://i.imgur.com/F8hu3Yo.png)
![](https://i.imgur.com/oohkXc9.png)
![](https://i.imgur.com/LZbuM23.png)
![](https://i.imgur.com/ahP0Uzf.png)
![](https://i.imgur.com/deq5cto.png)

## 🐪第四章(2) 2022/3/29
![](https://i.imgur.com/Dbac9Tt.png)
![](https://i.imgur.com/N6Ju8MJ.png)
![](https://i.imgur.com/e4WEVj8.png)
![](https://i.imgur.com/3TMuDiD.png)
![](https://i.imgur.com/uXiF7Yu.png)
![](https://i.imgur.com/EY6nrJo.png)
![](https://i.imgur.com/EjdnorB.png)

## 🐪第五章(1) 2022/5/10
![](https://i.imgur.com/o3UxHn6.png)
![](https://i.imgur.com/KFipUZA.png)
![](https://i.imgur.com/EGaQ42i.png)
### 5-13範例
```python=

def main() : 
   year = eval(input())  
   while year != -9999:
        isLeap(year)
        year = eval(input())

def isLeap(year):
  if year%400==0:
        print('%d is leap year.'%year)
  elif year%100==0:
        print('%d is not leap year.'%year)
  elif year%4==0:
        print('%d is leap year.'%year)
  else:
        print('%d is not leap year.'%year)

main()
```

### 5-14範例
```python=
def factor(c) :
    ans=1
    for i in range(1,c+1):
        ans*=i
    return ans
def main():
    n=int(input())
    for i in range(1,n+1):
        print("{:>2d}! = {:<d}".format(i,factor(i))) 
main()
```

### 11-4
```python=
def add(n1,n2) : 
    return n1+n2
def sub(n1,n2) : 
    return n1-n2
def mul(n1,n2) : 
    return n1*n2
def div(n1,n2) : 
    return n1/n2
def main():
  n1=int(input('請輸入第1個數字 = '))
  n2=int(input('請輸入第2個數字 = '))
  a=str(input('請輸入運算子(+,-,*,/) : '))
  if(a=='+'):
      print('計算結果 = ',str(add(n1,n2)))
  if(a=='-'):
      print('計算結果 = ',str(sub(n1,n2)))
  if(a=='*'):
      print('計算結果 = ',str(mul(n1,n2)))
  if(a=='/'):
      print('計算結果 = ',str(div(n1,n2)))
  else :
      print('運算公式輸入錯誤')
main()
```




## 🐪第六章(1)2022/5/17
### 擷取6-1
```python=
class Myschool:
    title = "明志科大 "
    def departments(self):
        a=['機械','電機','化工']
        return a
n = Myschool()
print(n.title)
a=n.departments()
for i in range(0,len(a)):
    print(a[i])

```

### 擷取6-2
```python=
import math
class Geometric:
   color='Green'
class Circle(Geometric):
   def __init__(self, radius):
        self.radius = radius
   def getRadius(self) : 
       return self.radius
   def setRadius(self,radius) :
       self.radius = radius 
       return self.radius
   def getDiameter(self) : 
       return self.radius*2
   def getPerimeter(self) : 
       return math.pi*self.radius*2
   def getArea(self) : 
       return math.pi*self.radius*self.radius
   def getColor(self) : 
       return Geometric.color

A = Circle(5)
print('圓形的顏色 : ',A.color)
print('圓形的半徑 : ',A.getRadius())
print('圓形的直徑 : ',A.getDiameter())
print('圓形的圓周 : ',A.getPerimeter())
print('圓形的面積 : ',A.getArea())
A.setRadius(10)
print('圓形的直徑 : ',A.getDiameter())
```

