Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's key was broken until after completing the calculation. She wants your help finding the difference between her miscalculation (using salaries with any zeros removed), and the actual average salary.
Write a query calculating the amount of error (i.e.: average monthly salaries), and round it up to the next integer.
SELECT
CEIL(AVG(Salary) - AVG(REPLACE(Salary, 0, '')))
FROM
employees
;
→ round it up이 "올림"하라는 뜻이라 CEIL 써야 함!
SELECT
months*salary AS earnings
, COUNT(*)
FROM
Employee
GROUP BY
months*salary
ORDER BY
months*salary DESC
LIMIT 1
;
def solution(babbling):
answer = 0
sound = ['aya', 'ye', 'woo', 'ma']
for i in babbling:
for j in sound:
if j*2 not in i:
i = i.replace(j, ' ')
if i.isspace():
answer += 1
return answer
→ for i in babbling:
: babbling 원소 하나씩 확인
→ if j*2 not in i:
: 연속으로 같은 발음을 하는 경우가 아닐 때
→ i = i.replace(j, ' ')
babbling 원소 속 sound 원소를 공백(space)으로 대체
※ whitespace와 space
화이트 스페이스는 화면상에는 표시하지 않지만 컴퓨터 모니터나 프린터와 같은 출력장치를 제어하는 문자
공백문자(space)는 화이트 스페이스 중 하나임
import string
string.whitespace
[실행결과]
' \t\n\r\x0b\x0c'
정규표현식 \s
== [ \t\n\r\f\v]
(맨 앞의 빈 칸은 공백문자(space)를 의미)
def solution(babbling):
count = 0
for b in babbling:
if "ayaaya" in b or "yeye" in b or "woowoo" in b or "mama" in b:
continue
if not b.replace("aya", " ").replace("ye", " ").replace("woo", " ").replace("ma", " ").replace(" ", ""):
count += 1
return count
def solution(babbling):
answer = 0
for word in babbling:
for pro in ["aya", "ye", "woo", "ma"]:
if pro * 2 not in word:
word=word.replace(pro,'1')
if word.isdigit():
answer+=1
return answer
def solution(babbling):
answer = 0
for i in babbling:
for j in ['aya','ye','woo','ma']:
if j*2 not in i:
i=i.replace(j,' ')
if len(i.strip())==0:
answer +=1
return answer
def solution(babbling):
dictionary = {"aya": 3, "ye": 2, "woo": 3, "ma": 2}
answer = 0
for b in babbling:
temp = b
check = True
before = ""
while temp:
if temp[:3] in dictionary:
if before == temp[:3]:
check = False
break
before = temp[:3]
temp = temp[3:]
elif temp[:2] in dictionary:
if before == temp[:2]:
check = False
break
before = temp[:2]
temp = temp[2:]
else:
check = False
break
if check:
answer += 1
return answer
def solution(babbling):
n = ["aya", "ye", "woo", "ma"]
for k, i in enumerate(babbling):
for j in n:
if j*2 in i:break
babbling[k]=babbling[k].replace(j, " ")
babbling[k]=babbling[k].replace(" ", "")
return babbling.count("")