###### tags: `APCS檢定營隊` # Day1 Answer ## p1 ```python= #!/usr/bin/python print('Hello World') ``` ## p2 ```python= a = 1.1 b = True c = 'Hello World' print(c) print(b) print(a) ``` ## p10 ```python= #!/usr/bin/python a = input() print(a.upper()) print(a.lower()) print(a.capitalize()) print(a.find('chino')) print(a.find('gary')) ``` ## p3 ```python= import math a = int(input()) b = int(input()) c = int(input()) print((-b+math.sqrt(b*b-4*a*c))/(2*a)) print((-b-math.sqrt(b*b-4*a*c))/(2*a)) ``` ## p5 ```python= x = int(input()) y = int(input()) print(x//y) print(x % y) ``` ## p11 ```python= weight = float(input()) height = float(input()) t = height*100 print("height:{}cm,weight:{}kg".format(t, weight)) print("BMI:{}".format(weight/(height**2))) ``` ## p12 ```python= # -*- coding: utf-8 -*- import random a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) f = int(input()) print(f'chinese:{a}') print(f'english:{b}') print(f'math:{c}') print(f'avg:{(a*d+b*e+c*f)/(d+e+f)}') ``` ## p14 ```python= # -*- coding: utf-8 -*- import random r = random.SystemRandom() a = int(input()) b = int(input()) c = int(input()) if (a>=30 and b==0)or c>=85: print('open') else: print("Don't open") ``` ## p3 ```python= a = float(input()) b = bool(input()) c = str(input()) print(type(c)) print(type(b)) print(type(a)) ``` ## p16 ```python= # -*- coding: utf-8 -*- import random a = int(input()) b = int(input()) c = int(input()) ammount = 0 p = a if p<=10: ammount+=380* a elif 11<=p and p<=20: ammount += 380 * 0.9 * a elif 21 <= p and p<=30: ammount += 380 * 0.85* a else: ammount += 380 * 0.8* a p = b if p<=10: ammount+=1200* b elif 11<=p and p<=20: ammount += 1200 * 0.95* b elif 21 <= p and p<=30: ammount += 1200 * 0.85* b else: ammount += 1200 * 0.8* b p = c if p<=10: ammount+=180* c elif 11<=p and p<=20: ammount += 180 * 0.85* c elif 21 <= p and p<=30: ammount += 180 * 0.8* c else: ammount += 180 * 0.7* c print(ammount) ``` ## a003 ```python= M=int(input()) D=int(input()) S=(M*2+D)%3 if S==0: print("normal") if S==1: print("good") if S==2: print("very good") ``` ## P15 ```python= # -*- coding: utf-8 -*- import random r = random.SystemRandom() a = int(input()) b = int(input()) c = int(input()) if a**2+b**2==c**2: print('Right triangle') elif a**2+b**2<c**2: print("obtuse triangle") else: print("Acute triangle") ```