Say "Hello, World!" With Python
문제 출처 : https://www.hackerrank.com/challenges/py-hello-world/problem?isFullScreen=true
Say "Hello, World!" With Python | HackerRank
Get started with Python by printing to stdout.
www.hackerrank.com
<Problem>
"Hello, World!"를 출력해라.
<Solution>
print("Hello, World!")
Python If-Else
문제 출처 : https://www.hackerrank.com/challenges/py-if-else/problem?isFullScreen=true
Python If-Else | HackerRank
Practice using if-else conditional statements
www.hackerrank.com
<Problem>
n이 홀수이면 "Weird"를 출력해라.
n이 짝수이고 2 이상 5 이하이면 "Not Weird"를 출력해라.
n이 짝수이고 6 이상 20 이하이면 "Weird"를 출력해라.
n이 짝수이고 20보다 크면 "Not Weird"를 출력해라.
<Solution>
n=int(input())
if n%2!=0:
print("Weird")
elif n in range(2,6):
print("Not Weird")
elif n in range(6,21):
print("Weird")
else:
print("Not Weird")
Arithmetic Operators
문제 출처 : https://www.hackerrank.com/challenges/python-arithmetic-operators/problem?isFullScreen=true
Arithmetic Operators | HackerRank
Addition, subtraction and multiplication.
www.hackerrank.com
<Problem>
정수 a와 b의 합, 차, 곱을 구해라.
<Solution>
a=int(input())
b=int(input())
print(a+b)
print(a-b)
print(a*b)
Python : Division
문제 출처 : https://www.hackerrank.com/challenges/python-division/problem?isFullScreen=true
Python: Division | HackerRank
Division using __future__ module.
www.hackerrank.com
<Problem>
정수 a와 b의 나눗셈을 해라.
첫 번째 줄에는 정수형의 몫이 나오도록 해라.
두 번째 줄에는 실수형의 몫이 나오도록 해라.
<Solution>
a=int(input())
b=int(input())
print(a//b)
print(a/b)
Loops
문제 출처 : https://www.hackerrank.com/challenges/python-loops/problem?isFullScreen=true
Loops | HackerRank
Practice using "for" and "while" loops in Python.
www.hackerrank.com
<Problem>
정수 n을 입력하고, n보다 작은 음이 아닌 정수 i의 제곱을 출력해라.
<Solution>
n=int(input())
for i in range(n):
print(i**2)
Write a function
문제 출처 : https://www.hackerrank.com/challenges/write-a-function/problem?isFullScreen=true
Write a function | HackerRank
Write a function to check if the given year is leap or not
www.hackerrank.com
<Problem>
연도가 주어지면 윤년인지 아닌지를 판별해라.
윤년이면 True, 윤년이 아니면 False를 반환해라.
윤년을 식별하는 조건은 다음과 같다.
[조건1] 연도가 4로 나누어떨어지면 윤년이다.
[조건2] 하지만 연도가 100으로 나누어떨어지면 윤년이 아니다.
[조건3] 하지만 연도가 400으로 나누어떨어지면 윤년이다.
<Solution>
def is_leap(year):
if year%4==0 and year%100!=0 or year%400==0:
return True
else:
return False
year=int(input())
print(is_leap(year))
Print Function
문제 출처 : https://www.hackerrank.com/challenges/python-print/problem?isFullScreen=true
Print Function | HackerRank
Learn to use print as a function
www.hackerrank.com
<Problem>
정수 n을 입력하고, 1부터 n까지의 정수를 출력해라.
<Solution>
n=int(input())
for i in range(1,n+1):
print(i,end="")
'HackerRank > Python' 카테고리의 다른 글
[Python] Strings (2) (0) | 2022.05.13 |
---|---|
[Python] Strings (1) (0) | 2022.05.11 |
[Python] Basic Data Types (2) (0) | 2022.04.14 |
[Python] Basic Data Types (1) (0) | 2022.04.13 |