Do it! 점프 투 파이썬 3

Do it! 점프 투 파이썬 - 4강 되새김 문제 풀이

C:\doit>python myargv.py 1 2 3 4 5 6 7 8 9 10 55 # 결괏값 Q1. 홀수, 짝수 판별하기: 홀수면 True, 짝수면 False를 리턴해야 한다. def is_odd(number): if number % 2 == 1: return True else: return False print(is_odd(1)) print(is_odd(2)) print(is_odd(3)) print(is_odd(4)) True False True False Q2. 모든 입력의 평균값 구하기: 입력으로 들어오는 모든 수의 평균값을 계산해 주는 함수를 작성해 보자. 단, 입력으로 들어오는 수의 개수는 정해져 있지 않다. def avg_numbers(): result = 0 for i in args:..

Do it! 점프 투 파이썬 - 3강 되새김 문제 풀이

Q1. 조건문의 참과 거짓: 다음 코드의 결괏값은? a = "Life is too short, you need python" if "wife" in a: print("wife") elif "pyhthon" in a and "you" not in a: print("python") elif "shirt" not in a: print("shirt") elif "need" in a: print("need") else: print("none") shirt # 차례대로 조건문에 넣어보면 답이 나온다 Q2. 3의 배수의 합 구하기 result = 0 i = 1 while i 5 :break print("*"*i) * ** *** **** ***** Q4. 1부터 100까지 출력하기: for문을 사용해서 1부터 100..

Do it! 점프 투 파이썬 - 2강 되새김 문제 풀이

Q1. #평균 점수 구하기 score = (80, 75, 55) result = 0 for i in score: result += i print(f'average : {result / len(score)}') average : 70.0 Q2. # 홀수, 짝수 판별하기 a = 13 if a % 2 == 0: print("짝숨다") else: print("홀숨다") 홀숨다 Q3. # 주민등록번호 나누기 pin = "881120 - 1068234" yyyymmdd = pin[0:6] num = pin [9:16] print(yyyymmdd) print(num) 881120 1068234 Q4. # 주민등록번호 인덱싱, 성별을 나타내는 숫자를 출력 pin = "881120 - 1068234" print(pin[..