> 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="")
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dailyjournal.gitbook.io/solutions/hackerrank-solutions/prepare/python/introduction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
