# Functions - no parameters

{% code title="intro.py" %}

```python
def main():
  done = False
  while not done:
    print("Menu")
    print("D - Do Now")
    print("Q - Quit")
    choice = input("Choice: ")
    if choice == "D":
        print("Do Now")
        name = input("What's your name")
        print(name,"welcome back!")
    elif choice == "Q":
        print("Exiting Game!")
        done = True

main()
```

{% endcode %}

### Example 1

Create a function named e1.

Using a for loop, print your name 5 times.

Call the function e1 within the main function.<br>

{% code title="example1.py" %}

```python
def main():
  done = False
  while not done:
    print("Menu")
    print("D - Do Now")
    print("E1 - Example 1")
    print("Q - Quit")
    choice = input("Choice: ")
    if choice == "D":
        print("Do Now")
        name = input("What's your name")
        print(name,"welcome back!")
    elif choice == "Q":
        print("Exiting Game!")
        done = True
    elif choice == "E1":
        e1()

def e1():
  name = input("What's your name: ")
  for i in range(5):
    print(name)

main()

```

{% endcode %}

### **Example 2**

Create a function named e2.

Using a for loop, print numbers from 0 to 4.

Call the function e2 within the main function.<br>

{% code title="example2.py" %}

```python
def main():
  done = False
  while not done:
    print("Menu")
    print("D - Do Now")
    print("E2 - Example 2")
    print("Q - Quit")
    choice = input("Choice: ")
    if choice == "D":
        print("Do Now")
        name = input("What's your name")
        print(name,"welcome back!")
    elif choice == "Q":
        print("Exiting Game!")
        done = True
    elif choice == "E2":
        e2()

def e2():
  for i in range(5):
    print(i)

main()
```

{% endcode %}

### **Example 3**

Create a function named e3.

Using a for loop, create a table to show the numbers -5 to 5 and their squares.  Create a header

print("Number\tSquared")

Call the function e3 within the main function.<br>

{% code title="example3.py" %}

```python
def main():
  done = False
  while not done:
    print("Menu")
    print("D - Do Now")
    print("E3 - Example 3")
    print("Q - Quit")
    choice = input("Choice: ")
    if choice == "D":
        print("Do Now")
        name = input("What's your name")
        print(name,"welcome back!")
    elif choice == "Q":
        print("Exiting Game!")
        done = True
    elif choice == "E3":
        e3()

def e3():
  print("Number\tSquared")
  for i in range(-5, 6):
    print(i,"\t",i**2)

main()
```

{% endcode %}

### **Example 4**

Create a function named e4.

Write Python code that converts Celsius to Fahrenheit for the following values of Celsius: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.

Use the following formula:

F=&#x39;**/**&#x35;C+32

Create a header:

print("Celsius\tFahrenheit")

Call the function e4 within the main function.<br>

{% code title="example4.py" %}

```python
def main():
  done = False
  while not done:
    print("Menu")
    print("D - Do Now")
    print("E4 - Example 4")
    print("Q - Quit")
    choice = input("Choice: ")
    if choice == "D":
        print("Do Now")
        name = input("What's your name")
        print(name,"welcome back!")
    elif choice == "Q":
        print("Exiting Game!")
        done = True
    elif choice == "E4":
        e4()

def e4():
  print("Celsius\tFahrenheit")
  for x in range(0,101,10):
    print(x,"\t",9/5*x + 32)

main()
```

{% endcode %}


---

# Agent Instructions: 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://www.pythonclassroom.com/functions/functions-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.
