목록Python Algorithm (133)
cool hamsters never sleep
hello = input() if (hello.startswith(" ") == True) and (hello.endswith(" ") == True) : print(hello.count(" ")-1) elif hello.startswith(" ") == True : print(hello.count(" ")) elif hello.endswith(" ") == True : print(hello.count(" ")) else : print(hello.count(" ")+1) 1. 문자의 첫 시작을 알 수 있는 함수 문자변수.startswith("찾으려는 문자") 있으면 True, 없으면 False 반환 2. 문자의 끝을 알 수 있는 함수 문자변수.endswith("찾으려는 문자") 있으면 True, 없으면 ..
A, B = map(int, input().split()) A = (A // 100) + (((A % 100) // 10) * 10) + ((A % 10) * 100) B = (B // 100) + (((B % 100) // 10) * 10) + ((B % 10) * 100) if A > B : print(A) else : print(B) 혹시 숫자를 역수로 바꾸는 더 좋은 방법이 있다면 댓글로 남겨주세요
#2440. 별 찍기 - 3 N = int(input()) for i in range(N+1) : print("*" * (N-i))
n = int(input()) number = input() a = list(map(int, number)) print(sum(a))
a = input() print(ord(a)) 1. 문자을 아스키코드로 변환 ord(문자) 2. 아스키코드를 문자로 변환 chr(문자)
n = int(input()) for _ in range(n): nums = list(map(int, input().split())) avg = sum(nums[1:])/nums[0] # 평균을 구함 (nums[0]: 학생수, nums[1:] 점수) cnt = 0 for score in nums[1:]: if score > avg: cnt += 1 # 평균 이상인 학생 수 rate = cnt/nums[0] *100 print(f'{rate:.3f}%') 1. %f 실수 받을 때 사용 2. f'{rate:.3f}%' 해석 rate에 담긴 수의 소수점 3자리까지 표기