일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- tableView
- suffix()
- swift
- MVC
- IOS
- String()
- uikit
- 프로그래머스
- Segue
- alamofire
- components()
- 라이징캠프
- uisearchbar
- Autolayout
- joined()
- 대문자소문자
- 코딩테스트
- github
- Info.plist
- reduce()
- zip()
- 코드업 파이썬 기초 100제
- xib
- 싱글톤
- API
- replacesubrange()
- GIT
- prefix()
- 알고리즘
- 클론코딩
- Today
- Total
Daeng iOS
[코드업 CodeUp] Python 기초 100제 (6061~6070) 본문
[코드업 CodeUp] Python 기초 100제 (6061~6070)
U_Daeng 2022. 8. 26. 01:01[문제집 링크]
https://codeup.kr/problemsetsol.php?psid=33
문제집 / Python 기초 100제
codeup.kr
[깃허브]
https://github.com/yujeong-kwon/Coding-test/tree/master/Codeup
GitHub - yujeong-kwon/Coding-test: 코딩테스트 공부
코딩테스트 공부. Contribute to yujeong-kwon/Coding-test development by creating an account on GitHub.
github.com
6061부터 6070까지는 비트단위논리연산, 3항연산, 조건/선택실행구조였다
#6061 - 비트단위로 OR하여 출력하기
입력된 정수 두 개를 비트단위로 or 연산한 후 그 결과를 정수로 출력
내 풀이
import sys
input = sys.stdin.readline
a, b = map(int,input().rstrip().split())
print(a|b)
모범 풀이
a, b = input().split()
print(int(a) | int(b))
#6062 - 비트단위로 XOR하여 출력하기
입력된 정수 두 개를 비트단위로 xor 연산한 후 그 결과를 정수로 출력
내 풀이
import sys
input = sys.stdin.readline
a, b = map(int,input().rstrip().split())
print(a^b)
모범 풀이
a, b = input().split()
print(int(a) ^ int(b))
#6063 - 정수 2개 입력받아 큰 값 출력하기
입력된 두 정수(a, b) 중 큰 값을 출력
내 풀이
import sys
input = sys.stdin.readline
a, b = map(int,input().rstrip().split())
print(a if (a>b) else b)
모범 풀이
a, b = input().split()
a = int(a)
b = int(b)
c = a if a>=b else b
print(c)
#6064 - 정수 3개 입력받아 가장 작은 값 출력하기
입력된 세 정수 a, b, c 중 가장 작은 값을 출력
내 풀이
import sys
input = sys.stdin.readline
a, b, c = map(int, input().rstrip().split())
print((a if (a<b) else b) if ((a if (a<b) else b)<c) else c)
모범 풀이
a, b, c = input().split()
a = int(a) #변수 a에 저장되어있는 값을 정수로 바꾸어 다시 변수 a에 저장
b = int(b)
c = int(c)
d = a if a<b else b
e = d if d<c else c
print(e)
#6065 - 정수 3개 입력받아 짝수만 출력하기
3개의 정수(a, b, c)가 입력되었을 때, 짝수만 출력
내 풀이
import sys
input = sys.stdin.readline
arr = list(map(int, input().rstrip().split()))
for i in arr:
if i % 2 == 0:
print(i)
모범 풀이
a, b, c = input().split()
a=int(a)
b=int(b)
c=int(c)
if a%2==0:
print(a)
if b%2==0:
print(b)
if c%2==0:
print(c)
#6066 - 정수 3개 입력받아 짝/홀 출력하기
3개의 정수(a, b, c)가 입력되었을 때, 짝(even)/홀(odd)을 출력
내 풀이
import sys
input = sys.stdin.readline
arr = list(map(int, input().rstrip().split()))
for i in arr:
if i % 2 == 0:
print("even")
else:
print("odd")
모범 풀이
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a%2==0:
print("even")
else:
print("odd")
if b%2==0:
print("even")
else:
print("odd")
if c%2==0:
print("even")
else:
print("odd")
#6067 - 정수 1개 입력받아 분류하기
0이 아닌 정수 1개가 입력되었을 때, 음(-)/양(+)과 짝(even)/홀(odd)을 구분해 분류
내 풀이
import sys
input = sys.stdin.readline
n = int(input().rstrip())
if n<0 and n%2==0:
print("A")
elif n<0 and n%2!=0:
print("B")
elif n>0 and n%2==0:
print("C")
else:
print("D")
모범 풀이
n=int(input())
if n<0:
if n%2==0:
print('A')
else:
print('B')
else:
if n%2==0:
print('C')
else:
print('D')
#6068 - 점수 입력받아 평가 출력하기
점수(정수, 0 ~ 100)를 입력받아 평가를 출력
내 풀이
import sys
input = sys.stdin.readline
n = int(input().rstrip())
if n>=90 and n<=100:
print("A")
elif n>=70 and n<90:
print("B")
elif n>=40 and n<=70:
print("C")
else:
print("D")
모범 풀이
a=int(input())
if a>=90:
print("A")
elif a>=70:
print("B")
elif a>=40:
print("C")
else:
print("D")
#6069 - 평가 입력받아 다르게 출력하기
평가를 문자(A, B, C, D, ...)로 입력받아 내용을 다르게 출력
내 풀이
import sys
input = sys.stdin.readline
str = input().rstrip()
if str=="A":
print("best!!!")
elif str=="B":
print("good!!")
elif str=="C":
print("run!")
elif str=="D":
print("slowly~")
else:
print("what?")
모범 풀이
a=input()
if a=='A':
print("best!!!")
elif a=='B':
print("good!!")
elif a=='C':
print("run!")
elif a=='D':
print("slowly~")
else:
print("what?")
#6070 - 월 입력받아 계절 출력하기
월이 입력될 때 계절 이름이 출력
내 풀이
import sys
input = sys.stdin.readline
str = int(input().rstrip())
if str//3 == 1:
print("spring")
elif str//3 == 2:
print("summer")
elif str//3 == 3:
print("fall")
else:
print("winter")
모범 풀이
a=int(input())
if a//3==1:
print("spring")
elif a//3==2:
print("summer")
elif a//3==3:
print("fall")
else:
print("winter")
'알고리즘 & 코딩테스트 > CodeUp : Python 기초 100제' 카테고리의 다른 글
[코드업 CodeUp] Python 기초 100제 (6071~6080) (0) | 2022.08.26 |
---|---|
[코드업 CodeUp] Python 기초 100제 (6051~6060) (0) | 2022.08.26 |
[코드업 CodeUp] Python 기초 100제 (6041~6050) (0) | 2022.03.05 |
[코드업 CodeUp] Python 기초 100제 (6031~6040) (0) | 2022.02.08 |
[코드업 CodeUp] Python 기초 100제 (6021~6030) (0) | 2022.02.07 |