> For the complete documentation index, see [llms.txt](https://www.pythonclassroom.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pythonclassroom.com/functions/functions-introduction.md).

# 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
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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.pythonclassroom.com/functions/functions-introduction.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
