일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- uisearchbar
- replacesubrange()
- Autolayout
- components()
- uiimage
- alamofire
- xib
- MVC
- GIT
- API
- map()
- prefix()
- 클론코딩
- 싱글톤
- github
- 대문자소문자
- Segue
- 라이징캠프
- print()
- 알고리즘
- 코딩테스트
- swift
- Info.plist
- UIImageView
- uikit
- 프로그래머스
- joined()
- tableView
- 코드업 파이썬 기초 100제
- IOS
- Today
- Total
Daeng iOS
[코드업 CodeUp] Python 기초 100제 (6071~6080) 본문
[코드업 CodeUp] Python 기초 100제 (6071~6080)
U_Daeng 2022. 8. 26. 01:04[문제집 링크]
https://codeup.kr/problemsetsol.php?psid=33
[깃허브]
https://github.com/yujeong-kwon/Coding-test/tree/master/Codeup
6071부터 6080까지는 반복실행구조, 종합 문제였다
#6071 - 0 입력될 때까지 무한 출력하기
0이 아니면 입력된 정수를 출력하고, 0이 입력되면 출력을 중단
내 풀이
import sys
input = sys.stdin.readline
#처음 조건 검사를 통과하기 위해 0이 아닌 값을 임의로 저장
n = 1
while n!=0:
n = int(input().rstrip())
if n!=0:
print(n)
모범 풀이
while True:
a=input()
a=int(a)
if a==0:
break
else:
print(a)
#6072 - 정수 1개 입력받아 카운트다운 출력하기1
정수(1 ~ 100) 1개가 입력되었을 때 카운트다운을 출력
내 풀이
import sys
input = sys.stdin.readline
n = int(input().rstrip())
for i in range(n,0,-1):
print(i)
모범 풀이
a=int(input())
while a!=0:
print(a)
a=a-1
#6073 - 정수 1개 입력받아 카운트다운 출력하기2
정수(1 ~ 100) 1개가 입력되었을 때 카운트다운을 출력
내 풀이
import sys
input = sys.stdin.readline
n = int(input().rstrip())
while n>0:
n = n - 1
print(n)
모범 풀이
a=int(input())
while a!=0:
a=a-1
print(a)
#6074 - 문자 1개 입력받아 알파벳 출력하기
영문 소문자(a ~ z) 1개가 입력되었을 때, a부터 그 문자까지의 알파벳을 순서대로 출력
내 풀이
import sys
input = sys.stdin.readline
str = ord(input().rstrip())
a = ord("a")
while a <= str:
print(chr(a), end=" ")
a = a + 1
모범 풀이
c=input()
i = ord('a')
c = ord(c)
while i<=c:
print(chr(i), end=' ')
i+=1
#6075 - 정수 1개 입력받아 그 수까지 출력하기1
정수(0 ~ 100) 1개를 입력받아 0부터 그 수까지 순서대로 출력
내 풀이
import sys
input = sys.stdin.readline
n = int(input().rstrip())
i = 0
while i <= n:
print(i)
i += 1
모범 풀이
n=int(input())
i=0
while i<=n:
print(i)
i+=1
#6076 - 정수 1개 입력받아 그 수까지 출력하기2
정수(0 ~ 100) 1개를 입력받아 0부터 그 수까지 순서대로 출력
내 풀이
import sys
input = sys.stdin.readline
n = int(input().rstrip())
i = 0
while i <= n:
print(i)
i += 1
모범 풀이
n=int(input())
for i in range(n+1):
print(i)
#6077 - 짝수 합 구하기
정수(1 ~ 100) 1개를 입력받아 1부터 그 수까지 짝수의 합을 구하기
내 풀이
import sys
input = sys.stdin.readline
n = int(input().rstrip())
i = 0
s = 0
while i <= n:
if i % 2 == 0:
s += i
i += 1
print(s)
모범 풀이
n = int(input())
sum=0
for i in range(1, n+1):
if i%2==0:
sum=sum+i
print(sum)
#6078 - 원하는 문자가 입력될 때까지 반복 출력하기
영문 소문자 'q' 가 입력될 때까지 입력한 문자를 계속 출력
내 풀이
import sys
input = sys.stdin.readline
while 1:
str = input().rstrip()
print(str)
if str == "q":
break
모범 풀이
while True:
x=input()
print(x)
if x=='q':
break
#6079 - 언제까지 더해야 할까?
1, 2, 3 ... 을 계속 더해 나갈 때, 그 합이 입력한 정수(0 ~ 1000)보다 같거나 작을 때까지만 계속 더하는 프로그램
내 풀이
from re import I
import sys
input = sys.stdin.readline
n = int(input().rstrip())
i = 0
s = 0
while s < n:
i += 1
s += i
print(i)
모범 풀이
n = int(input())
s = 0
t = 0
while s<n :
t = t+1
s = s+t
print(t)
#6080 - 주사위 2개 던지기
1부터 n까지, 1부터 m까지 숫자가 적힌 서로 다른 주사위 2개를 던졌을 때, 나올 수 있는 모든 경우를 출력
내 풀이
import sys
input = sys.stdin.readline
n, m = map(int,input().rstrip().split())
for i in range (1, n+1):
for j in range (1, m+1):
print(i, j)
모범 풀이
n,m=input().split()
n=int(n)
m=int(m)
for i in range(1, n+1) :
for j in range(1, m+1) :
print(i, j)
'알고리즘 & 코딩테스트 > CodeUp : Python 기초 100제' 카테고리의 다른 글
[코드업 CodeUp] Python 기초 100제 (6061~6070) (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 |