> For the complete documentation index, see [llms.txt](https://dailyjournal.gitbook.io/solutions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dailyjournal.gitbook.io/solutions/hackerrank-solutions/prepare/python/introduction.md).

# Introduction

## Say "Hello, World!" With Python

{% embed url="<https://www.hackerrank.com/challenges/py-hello-world/problem?isFullScreen=true>" %}

```python
print("Hello, World!")
```

## Python If-Else

{% embed url="<https://www.hackerrank.com/challenges/py-if-else/problem?isFullScreen=true>" %}

```python
#!/bin/python3

import math
import os
import random
import re
import sys



if __name__ == '__main__':
    n = int(input().strip())
    if (n % 2) != 0:
        print("Weird")
    else:
        if n >= 2 and n <= 5:
            print("Not Weird")
        elif n >= 6 and n <= 20:
            print("Weird")
        elif n > 20:
            print("Not Weird")
```

## Arithmetic Operators

{% embed url="<https://www.hackerrank.com/challenges/python-arithmetic-operators/problem?isFullScreen=true>" %}

```python
if __name__ == '__main__':
    a = int(input())
    b = int(input())
    print(a + b)
    print(a - b)
    print(a * b)
```

## Python: Division

{% embed url="<https://www.hackerrank.com/challenges/python-division/problem?isFullScreen=true>" %}

```python
if __name__ == '__main__':
    a = int(input())
    b = int(input())
    print(a // b)
    print(a / b)
```

## Loops

{% embed url="<https://www.hackerrank.com/challenges/python-loops/problem?isFullScreen=true>" %}

```python
if __name__ == '__main__':
    n = int(input())
    for i in range(n):
        print(i * i)
```

## Write a function

{% embed url="<https://www.hackerrank.com/challenges/write-a-function/problem?isFullScreen=true>" %}

```python
def is_leap(year):
    leap = False
    
    # Write your logic here
    if year % 4 == 0:
        if year % 100 != 0 or year % 400 == 0:
            leap = True
            
    return leap

year = int(input())
```

## Print Function

{% embed url="<https://www.hackerrank.com/challenges/python-print/problem?isFullScreen=true>" %}

```python
if __name__ == '__main__':
    n = int(input())
    for i in range(1, n+1):
        print(i, end="")
```
