# python 作業
## BMI計算機
```python=
height = float(input("請輸入身高(公分)"))
weight = float(input("請輸入體重(公斤)"))
BMI = weight/(height/100)**2
print(BMI)
if BMI>=35:
print("重度肥胖")
elif BMI>=30 and BMI<35:
print("中度肥胖")
elif BMI>=27 and BMI<30:
print("輕度肥胖")
elif BMI>=24 and BMI<27:
print("過重")
elif BMI>=18.5 and BMI<24:
print("正常")
else :
print("體重過輕")
```
## python 100題 1-10題
```python=
#第1題
total = 0
for i in range(1,5):
for j in range(1,5):
for k in range(1,5):
if (i!=j) and (j!=k) and (i!=k):
print(i,j,k)
total+=1
---
#第2題
print(total)
profit = int(input())
if profit <= 100000:
bouns = profit*0.1
print(bouns)
elif profit > 100000 and profit <= 200000:
bouns = 100000*0.1 + (profit-100000)*0.075
print(bouns)
elif profit > 200000 and profit <= 400000:
bouns = 100000*0.1 + (200000-100000)*0.075 + (profit-200000)*0.05
print(bouns)
elif profit > 400000 and profit <= 600000:
bouns = 100000*0.1 + (200000-100000)*0.075 + (400000-200000)*0.05 + (profit-400000)*0.03
print(bouns)
elif profit > 600000 and profit <= 1000000:
bouns = 100000*0.1 + (200000-100000)*0.075 + (400000-200000)*0.05 + (600000-400000)*0.03 + (profit-600000)*0.015
print(bouns)
elif profit > 1000000 :
bouns = 100000*0.1 + (200000-100000)*0.075 + (400000-200000)*0.05 + (600000-400000)*0.03 + (1000000-600000)*0.015 + (profit-600000)*0.01
print(bouns)
---
#第2題
profit=int(input('Show me the money: '))
bonus=0
thresholds=[100000,100000,200000,200000,400000]
rates=[0.1,0.075,0.05,0.03,0.015,0.01]
for i in range(len(thresholds)):
if profit<=thresholds[i]:
bonus+=profit*rates[i]
profit=0
break
else:
bonus+=thresholds[i]*rates[i]
profit-=thresholds[i]
bonus+=profit*rates[-1]
print(bonus)
---
#第3題
n=0
while (n+1)**2-n*n<=168:
n+=1
for i in range((n+1)**2):
if i**0.5==int(i**0.5) and (i+168)**0.5==int((i+168)**0.5):
print(i-100)
---
#第4題
DofM=[0,31,28,31,30,31,30,31,31,30,31,30]
res=0
year=int(input('Year:'))
month=int(input('Month:'))
day=int(input('day:'))
if (year % 4 ==0 and year % 100 !=0) or (year % 400 ==0):
DofM[2]+=1
for i in range(month):
res+=DofM[i]
print(f"{year}到{month}月{day}日已經過了{res+day}天")
---
#第5題
raw = []
for i in range(3) :
a = int(input())
raw.append(a)
raw.sort()
print(raw)
---
#第6題
a,b=1 , 1
target = int(input())
print(1,end=" ")
for i in range(target-1):
a,b=b,a+b
print(a ,end=" ")
---
#第7題
import copy
a = [1,2,3,4,['a','b']]
b = a
c = a[:]
d = copy.copy(a)
e = copy.deepcopy(a)
a.append(5)
a[4].append('c')
print('a=',a)
print('b=',b)
print('c=',c)
print('d=',d)
print('e=',e)
---
#第8題
for i in range(1,10):
for j in range(1,i+1):
print(f"{i}*{j}={i*j:<3d}",end='')
print()
---
#第9題
import time
for i in range(4):
print(str(int(time.time()))[-2:])
time.sleep(1)
---
#第10題
import time
for i in range(4):
print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
time.sleep(1)
---
#第11題
month=int(input('要繁殖幾個月?: '))
month_1=1
month_2=0
month_3=0
month_elder=0
for i in range(month):
month_1,month_2,month_3,month_elder=month_elder+month_3,month_1,month_2,month_elder+month_3
print('第%d个月共'%(i+1),month_1+month_2+month_3+month_elder,'對兔子')
print('其中1月兔:',month_1)
print('其中2月兔:',month_2)
print('其中3月兔:',month_3)
print('其中成年兔:',month_elder)
---
#第12題
import math
final = int(input("請輸入最終數字"))
for i in range(2,final):
flag=0
for j in range(2,round(math.sqrt(i))+1):
if i%j==0:
flag=1
break
if flag:
continue
print(i)
---
#第13題
for i in range(100,1000):
s=str(i)
one=int(s[0])
ten=int(s[1])
hun=int(s[2])
if i == one**3+ten**3+hun**3:
print(i)
---
#第14題
target = int(input("輸入一個數字"))
print(target,"= ",end="")
if target< 0 :
print("-1*",end="")
target = abs(target)
flag = 0
if target<=1:
print(target)
flag = 1
while 1==1:
if flag :
break
for i in range(2,int(target+1)):
if target%i==0:
print(i,end="")
if target==i:
flag = 1
break
print("*",end="")
target/=i
break
---
#第15題
points=int(input('請輸入分數:'))
if points>=90:
grade='A'
elif points<60:
grade='C'
else:
grade='B'
print(grade)
---
#第16題
import datetime
print(datetime.date.today())
print(datetime.date(2333,2,3))
print(datetime.date.today().strftime('%d/%m/%Y'))
day=datetime.date(1111,2,3)
day=day.replace(year=day.year+22)
print(day)
---
#第17題
string=input("輸入字符串:")
alp=0
num=0
spa=0
oth=0
for i in range(len(string)):
if string[i].isspace():
spa+=1
elif string[i].isdigit():
num+=1
elif string[i].isalpha():
alp+=1
else:
oth+=1
print('space: ',spa)
print('digit: ',num)
print('alpha: ',alp)
print('other: ',oth)
---
#第18題
a=input('數字:')
n=int(input('幾次?:'))
res=0
for i in range(n):
res+=int(a)
a+=a[0]
print('結果:',res)
---
#第19題
def factor(num):
target=int(num)
res=set()
for i in range(1,num):
if num%i==0:
res.add(i)
res.add(num/i)
return res
for i in range(2,1001):
if i==sum(factor(i))-i:
print(i)
---
#第20題
high=100
total=100
for i in range(10):
high/=2
total+=high
print(high)
print('總長:',total)
---
#第21題
peach = 1
for i in range(9):
peach=(peach+1)*2
print(peach)
---
#第22題
a=set(['x','y','z'])
b=set(['x','y','z'])
c=set(['x','y','z'])
c-=set(('x','z'))
a-=set('x')
for i in a:
for j in b:
for k in c:
if len(set((i,j,k)))==3:
print('a:%s,b:%s,c:%s'%(i,j,k))
---
#第23題
def draw(num):
a="*"*(2*(4-num)+1)
print(a.center(9,' '))
if num!=1:
draw(num-1)
print(a.center(9,' '))
draw(4)
---
#第24題
a = 2.0
b = 1.0
for i in range(1,21):
s += a/b
a,b=a+b,a
print(s)
---
#第25題
a= 1
n = int(input("要幾階"))
for i in range(n,1,-1):
a=i*a+1
print(a)
---
#第26題
a= 1
n = int(input("要幾階"))
for i in range(n):
a*=(i+1)
print(a)
---
#第27題
n=input('輸入符號:')
n=str(n)
print(f"{len(n)}位數")
print(n[::-1])
---
#第28題
a= 10
age = 0
n = int(input("有幾人"))
for i in range(n):
age+=2
print(age+10)
---
#第29題
n=int(input('輸入正整數:'))
n=str(n)
print(f"{len(n)}位數")
print(n[::-1])
---
#第30題
n=input("輸入:")
a=0
b=len(n)-1
flag=True
while a<b:
if n[a]!=n[b]:
print('不是回文串')
flag=False
break
a,b=a+1,b-1
if flag:
print('是回文串')
---
```
## 電商平台作業
[電商平台](https://colab.research.google.com/drive/19h77abnXhDeaku28Q4HGVHu8PProiSbf?usp=sharing)