HackerRank-Python

Prepare > Python > Introduction

stem_sw 2023. 6. 17. 21:19

Python If-Else

if n%2 != 0:
    print('Weird')
else:
    if n <= 5 or n > 20:
        print('Not Weird')
    else:
        print('Weird')

 

Arithmetic Operators

print(a + b)
print(a - b)
print(a * b)

 

Loops

for i in range(n):
    print(i**2)

 

Write a function

if year % 400 == 0:
        leap = True
    elif (year % 100 != 0 and year % 4 == 0):
        leap = True
    return leap
  • 문제 이해 똑바로...영문 독해 이슈 ㅋㅋㅋ

 

Print Function

def replyer(n):
    for i in range(1, n+1):
        print(i, end='')   
    
replyer(n)