# 資訊課
---
## 1
### 1A
```python
# -*- coding: utf-8 -*-
"""class.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1Ag7LYTMbxO-6Gn04MOQYJsC6IKhcxKMH
"""
q, w, e ,r,t= int(input()), int(input()), int(input()) ,int(input()),int(input())
sum=q+w+e+r+t
print('sum:',sum)
avg=sum/5
#print(avg)
print('avg:{0:.2f}'.format(avg))
```
### 1B
```python
# -*- coding: utf-8 -*-
"""cl1b.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1Ag7LYTMbxO-6Gn04MOQYJsC6IKhcxKMH
"""
#q, w, e ,r,t= int(input()), int(input()), int(input()) ,int(input()),int(input())
q,w=float(input()),float(input())
v=q*q*3.1416*w
print('avg:{0:.4f}'.format(v))
```
## 4
### 4A
```python=
# This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
a=int(input())
if a < 0:
print('M')
elif a == 0:
print('Z')
elif a%2==0:
print('E')
elif a%2==1:
print('O')
```
### 4B
```python=
# This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
a=int(input())
b=int(input())
c=int(input())
d=(a+b+c)/3
if d>100:
print('BS')
elif d<0:
print('BS')
elif d>=60:
print('PASS')
elif d<60:
print('FAIL')
```
### 4C
```python=
# This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
a=int(input())
b=int(input())
c=int(input())
if a<60:
a=a*1.25
if b<60:
b=b*1.25
if c<60:
c=c*1.25
d=(a+b+c)/3
if d>=60:
print('Hmm')
else:
print('PleaseGoToDieOneDie')
```
### 4D
```python=
# This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
a=int(input())
if a>10000:
print(' Sleeping in school')
elif a<1500:
c=70
elif (a-1500)%500==0:
c=70+(5*(a-1500)/500)
print('{0:.0f}'.format(c))
else:
b=int((a-1500)/500)
b=b+1
c=70+5*b
print('{0:.0f}'.format(c))
```
### 4E
```python=
s =input()
slen =int((len(s)+1)/8)
for i in range(slen):
if s[i*8:i*8+7] == '0 1 0 1':
print('A',end= '')
elif s[i*8:i*8+7] == '0 1 1 1':
print('B',end= '')
elif s[i*8:i*8+7] == '0 0 1 0':
print('C',end= '')
elif s[i*8:i*8+7] == '1 1 0 1':
print('D',end= '')
elif s[i*8:i*8+7] == '1 0 0 0':
print('E',end= '')
elif s[i*8:i*8+7] == '1 1 0 0':
print('F',end= '')
```
### 4F
```python=
# This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
a=input()
try:
a=int(a)
if a>100 or a<0:
print('Error!')
elif a>=90:
print('Level A.')
print('Work hard play hard.')
elif a>=80:
print('Level B.')
print('Work hard play hard.')
elif a>=70:
print('Level C.')
print('Work hard play hard.')
elif a >= 60:
print('Level D.')
print('Work hard play hard.')
else:
print('Level E')
print('Play hard die hard.')
except:
print('-_-')
```
### 4G
```python=
# This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
web =input()
weblen =len(web)
if web[0:8] !='https://':
if web[0:7] =='http://' and web[weblen-15:] == 'tnfsh.tn.edu.tw':
print('OK!!')
else:
print('Invalid web site URL!')
elif web[weblen-9:] == 'tn.edu.tw':
print('OK!!')
else:
print('Invalid web site URL!')
```
## 5
### 5A
```python=
n=int(input())
s=1
if n>1:
for i in range(2,n+1):
s+=1/i
print('{0:0.4f}'.format(s))
```
### 5B
```python=
x=int(input())
s=0
for i in range(2,x):
if x%i==0:
s=s+i
else:
pass
if s==0:
print("XD")
else:
print(s)
```
### 5C
```python=
x=int(input())
y=int(input())
dic=[]
boo=0
for i in range(x,y+1):
sum=0
for j in range(1,i):
if i%j==0:
sum=sum+j
if sum==i:
print(sum)
boo=1
if boo==0:
print("No number is perfect")
```
### 5D
```python=
# -*- coding: utf-8 -*-
"""Untitled0.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1pzMjBGwp32Ns4Xxv6zpIdXDhVzSW_GRe
"""
a=input().split()
##print(a)
sum=0
for i in range(len(a)):
sum=sum+int(a[i])
##print(sum)
avg=sum/len(a)
##print(avg)
sumj=0
for i in range(len(a)):
sumj=sumj+(int(a[i])-avg)**2
##print(sumj)
sumj=sumj/len(a)
sumj=sumj**0.5
print('{:.3f}'.format(sumj))
```
### 5E
```python=
a=input().split()
a=[int(x) for x in a]
a.sort(reverse=True)
boa=0
bob=0
for i in range(len(a)-1):
print(a[i],end=' ')
print(a[(len(a)-1)])
for i in a:
if i<60:
print(i)
boa=1
break
if boa==0:
print('best case')
for i in reversed(a):
if i>= 60:
print(i)
bob = 1
break
if bob==0:
print('worst case')
```
## 6
### 6A
```python=
a=input()
sum=0
for i in a:
sum+=int(i)
print(sum)
```
### 6D
```python=
a = input().split()
a = list(map(int,a))
x,y = a[0],a[1]
n = ('start')
times=1
while n != a[2]:
n = (x+y)//2
print(times,end='')
print(': ',end='')
print(n)
if a[2] > n:
x=n+1
elif a[2] < n:
y=n-1
times+=1
```
### 6G
```python=
def cl(x):
i=1
if x==1:
return 1
while(x!=1):
if x%2==1:
x=3*x+1
i=i+1
else:
x=x/2
i=i+1
if x==1:
return i
try:
while True:
v=input().split()
i=int(v[0])
j=int(v[1])
if i>j:
i,j=j,i
ckp=0
for i in range(i,j+1):
if cl(i)>ckp:
ckp=cl(i)
print(v[0],end='')
print(' ',end='')
print(v[1],end='')
print(' ',end='')
print(ckp)
except EOFError:
pass
```
## 7
### 7A
```python=
a = int(input())
for i in range(a):
s=input()
if s=='0 1 0 1':
print('A',end="")
if s=='0 1 1 1':
print('B',end="")
if s=='0 0 1 0':
print('C',end="")
if s=='1 1 0 1':
print('D',end="")
if s=='1 0 0 0':
print('E',end="")
if s=='1 1 0 0':
print('F',end="")
print()
```
### 7B
```python=
#還沒完成
a = input()
suc=0
suo=0
if len(a)%2==1: #基數位
for i in range(0,len(a),2):
suc+=int(a[i])
for i in range(1,len(a),2):
suo+=int(a[i])
if suc-suo<0:
print(-1*(suc-suo))
else:
print(suc-suo)
```