일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- tableView
- reduce()
- joined()
- alamofire
- xib
- MVC
- Autolayout
- 싱글톤
- replacesubrange()
- github
- 코드업 파이썬 기초 100제
- 코딩테스트
- 알고리즘
- suffix()
- uikit
- prefix()
- Segue
- 대문자소문자
- String()
- GIT
- components()
- zip()
- IOS
- 라이징캠프
- uisearchbar
- API
- Info.plist
- 프로그래머스
- 클론코딩
- swift
- Today
- Total
Daeng iOS
[코드업 CodeUp] Python 기초 100제 (6051~6060) 본문
[코드업 CodeUp] Python 기초 100제 (6051~6060)
U_Daeng 2022. 8. 26. 00:56[문제집 링크]
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
6051부터 6060까지는 비교연산, 논리연산, 비트단위논리연산이다
#6051 - 정수 2개 입력받아 비교하기4
두 정수(a, b)를 입력받아 a의 값이 b의 값과 서로 다르면 True, 같으면 False를 출력
내 풀이
import sys
input = sys.stdin.readline
a, b = map(int, input().rstrip().split())
#if a != b:
# print(True)
#else:
# print(False)
if not a == b:
print(True)
else:
print(False)
모범 풀이
a, b = input().split()
a = int(a)
b = int(b)
print(a!=b)
#6052 - 정수 입력받아 참 거짓 평가하기
정수가 입력되었을 때, True/False로 평가
내 풀이
import sys
input = sys.stdin.readline
n = int(input().rstrip())
#if n == 0:
# print(False)
#else:
# print(True)
#bool()을 이용하면 입력된 식이나 값을 평가해 불 형의 값 (T/F)을 출력해준다
print(bool(n))
모범 풀이
n = int(input())
print(bool(n))
#6053 - 참 거짓 바꾸기
정수값이 입력될 때, 그 불 값을 반대로 출력
내 풀이
import sys
input = sys.stdin.readline
a = bool(int(input().rstrip()))
print(not a)
모범 풀이
a = bool(int(input()))
print(not a)
#6054 - 둘 다 참일 경우만 참 출력하기
2개의 정수값이 입력될 때, 그 불 값이 모두 True일 때에만 True를 출력
내 풀이
import sys
input = sys.stdin.readline
a, b = map(int,input().rstrip().split())
#if a and b == True:
# print(True)
#else:
# print(False)
print(bool(a) and bool(b))
모범 풀이
a, b = input().split()
print(bool(int(a)) and bool(int(b)))
#6055 - 하나라도 참이면 참 출력하기
2개의 정수값이 입력될 때, 그 불 값이 하나라도 True 일 때에만 True를 출력
내 풀이
import sys
input = sys.stdin.readline
a, b = map(int, input().rstrip().split())
print(bool(a) or bool(b))
모범 풀이
a, b = input().split()
print(bool(int(a)) or bool(int(b)))
#6056 - 참/거짓이 서로 다를 때에만 참 출력하기
2개의 정수값이 입력될 때, 그 불 값(True/False)이 서로 다를 때에만 True를 출력
내 풀이
import sys
input = sys.stdin.readline
a, b = map(int, input().rstrip().split())
print((bool(a) and not(bool(b))) or (not(bool(a)) and bool(b)))
모범 풀이
a, b=input().split()
c = bool(int(a))
d = bool(int(b))
print((c and (not d)) or ((not c) and d))
#6057 - 참/거짓이 서로 같을 때에만 참 출력하기
2개의 정수값이 입력될 때, 그 불 값(True/False) 이 서로 같을 때에만 True 를 출력
내 풀이
import sys
input = sys.stdin.readline
a, b = map(int,input().strip().split())
if bool(a) == bool(b):
print(True)
else:
print(False)
모범 풀이
a, b = input().split()
a = bool(int(a))
b = bool(int(b))
print(a==b)
a, b = input().split()
a = bool(int(a))
b = bool(int(b))
print((a and b) or (not a and not b))
#6058 - 둘 다 거짓일 경우만 참 출력하기
2개의 정수값이 입력될 때, 그 불 값(True/False) 이 모두 False 일 때에만 True 를 출력
내 풀이
import sys
input = sys.stdin.readline
a, b = map(int,input().strip().split())
if bool(a) == 0 and bool(b) == 0:
print(True)
else:
print(False)
모범 풀이
a, b = input().split()
c= bool(int(a))
d= bool(int(b))
print( not (c or d) )
a, b = input().split()
c= bool(int(a))
d= bool(int(b))
print( c==False and d==False )
#6059 - 비트단위로 NOT 하여 출력하기
입력된 정수를 비트단위로 참/거짓을 바꾼 후 정수로 출력
내 풀이
import sys
input = sys.stdin.readline
n = int(input().rstrip())
print(~n)
모범 풀이
a=int(input())
print(~a)
#6060 - 비트단위로 AND 하여 출력하기
입력된 정수 두 개를 비트단위로 and 연산한 후 그 결과를 정수로 출력
내 풀이
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))
'알고리즘 & 코딩테스트 > CodeUp : Python 기초 100제' 카테고리의 다른 글
[코드업 CodeUp] Python 기초 100제 (6071~6080) (0) | 2022.08.26 |
---|---|
[코드업 CodeUp] Python 기초 100제 (6061~6070) (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 |