본문 바로가기

Daily 코딩-Python18

[Python3] LeetCode 1번 (Two Sum)-이중 for loop 사용 문제 출처 및 KEYWORDS 분석 Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. 리트코드(LeetCode) 웹사이트에 있는 1번 문제로써 이 문제를 풀 때 중요한 KEYWORDS는 아래와 같다. array of integers nums an integer target ret.. 2022. 9. 26.
[파이썬] 백준 11021번(A+B-7)-print()활용법 문제 출처와 간단 설명 백준 코딩 [문제]->[단계별로 풀어보기]->[반복문]에 있는 백준 11021번 문제는 반복문, 정수를 입력받는 법, 그리고 print( ) 함수로 문자열(string)과 숫자를 동시에 출력하는 법을 요구한다. 이 포스팅에서 for loop과 while loop으로 푸는 방법과 print() 함수로 출력하는 두 가지 방식을 소개한다. Solution Version 1 t=int(input()) for i in range(1,t+1): #1~t a,b=map(int, input().split()) print("Case #{}: {}".format(i,a+b)) Version 2 t=int(input()) index=1 while index 2022. 9. 24.
[파이썬] 백준 25304번(영수증)-for loop과 while loop사용 문제 출처 및 간단 설명 백준 코딩 사이트에서 [문제]-->[단계별로 풀어보기]-->[반복문]에 있는 백준 25304번 문제는 정수형 숫자를 입력받는 방법과 문제 조건에 맞는 반복문과 조건문을 사용해 답을 출력을 요구하며 이 문제에 대한 Solution으로 for loop을 사용한 경우와 while loop을 사용한 각각의 경우의 코드를 설명한다. 입출력 방식, 반복문, 조건문의 사용을 동시에 연습할 수 있는 문제이다. Solution Version 1 x=int(input()) #total price n=int(input()) #number of products totalprice=0 #initilize the variable for i in range(n): a,b=map(int, input().sp.. 2022. 9. 24.
[파이썬] 백준 2525번 (오븐시계)-두 가지 풀이방식 문제 출처 및 간단 설명 백준 코딩 사이트에서 [문제]->[단계별로 풀어보기]->[조건문]에 있는 6단계인 2525번 문제는 한 줄에 여러 개의 정수를 입력받는 방법과 변수에 값을 할당하는 법, Arithmetic operator를 활용하는 법 그리고 문제에 맞게 조건문을 사용하는 방법 등을 요구하며 이 문제의 풀이 방식에는 두 가지 다른 version의 solution을 제공한다. Solution Version 1 a,b=map(int, input().split()) c=int(input()) if b+c=60: #만약 a=22, b+c//60=2이면 a=24인데 24를 24로 나눈 나머지는 0 #만약 a=20, b+c//60=2이면 a=22인데 22를 24로 나눈 나머지는 22 a=(a+((b+c)/.. 2022. 9. 21.