# Function Practice Questions

1. Write a function that takes two numbers as input and returns their sum.

```python
def add_numbers(num1, num2):
    return num1 + num2
```

2. Write a function that takes a list of numbers as input and returns the maximum value in the list.

```python
def find_max(numbers):
    return max(numbers)
```

3. Write a function that takes a string as input and returns the number of vowels in the string.

```cpp
def count_vowels(word):
    vowels = "aeiou"
    count = 0
    for char in word:
        if char.lower() in vowels:
            count += 1
    return count
```

4. Write a function that takes a list of words as input and returns a new list that contains only the words that start with a vowel.

```scss
def start_with_vowel(words):
    vowels = "aeiou"
    result = []
    for word in words:
        if word[0].lower() in vowels:
            result.append(word)
    return result
```

5. Write a function that takes a list of numbers as input and returns a new list that contains only the even numbers.

```python
def find_even(numbers):
    result = []
    for num in numbers:
        if num % 2 == 0:
            result.append(num)
    return result
```

6. Write a function that takes a string as input and returns the string in reverse order.

```ruby
def reverse_string(string):
    return string[::-1]
```

7. Write a function that takes a list of numbers as input and returns the average value of the numbers.

```python
def find_average(numbers):
    return sum(numbers) / len(numbers)
```

8. Write a function that takes a string as input and returns a new string that has all the vowels removed.

```c
def remove_vowels(string):
    vowels = "aeiou"
    result = ""
    for char in string:
        if char.lower() not in vowels:
            result += char
    return result
```

9. Write a function that takes a list of words as input and returns a new list that contains only the words that have more than five characters.

```python
def find_long_words(words):
    result = []
    for word in words:
        if len(word) > 5:
            result.append(word)
    return result
```

10. Write a function that takes a list of strings as input and returns a new list that contains the length of each string.

```go
def find_length(strings):
    result = []
    for string in strings:
        result.append(len(string))
    return result
```

11. Write a function that takes a list of numbers as input and returns the sum of the squares of all the numbers in the list.

```sql
def sum_of_squares(numbers):
    result = 0
    for num in numbers:
        result += num ** 2
    return result
```

12. Write a function that takes a string as input and returns the number of words in the string.

```python
def count_words(string):
    words = string.split()
    return len(words)
```

1. Write a Python function to find the maximum of three numbers.

```python
def find_max(a, b, c):
    return max(a, b, c)

print(find_max(5, 9, 3))  # Output: 9
```

2. Write a Python function to reverse a string.

```python
def reverse_string(s):
    return s[::-1]

print(reverse_string("hello"))  # Output: olleh
```

3. Write a Python function to check if a string is a palindrome.

```python
def is_palindrome(s):
    return s == s[::-1]

print(is_palindrome("racecar"))  # Output: True
```

4. Write a Python function to calculate the factorial of a number.

```python
def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)

print(factorial(5))  # Output: 120
```

5. Write a Python function to check if a number is prime.

```python
def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

print(is_prime(17))  # Output: True
```

6. Write a Python function to find the greatest common divisor (GCD) of two numbers.

```python
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

print(gcd(12, 8))  # Output: 4
```

7. Write a Python function to convert a string to title case.

```python
def to_title_case(s):
    return s.title()

print(to_title_case("the quick brown fox"))  # Output: The Quick Brown Fox
```

8. Write a Python function to calculate the area of a circle.

```python
def circle_area(radius):
    return 3.14 * radius**2

print(circle_area(5))  # Output: 78.5
```

9. Write a Python function to generate a list of all prime numbers up to a given number.

```python
def primes_up_to(n):
    primes = []
    for num in range(2, n+1):
        if is_prime(num):
            primes.append(num)
    return primes

print(primes_up_to(20))  # Output: [2, 3, 5, 7, 11, 13, 17, 19]
```

10. Write a Python function to calculate the Fibonacci sequence up to a given number of terms.

```python
def fibonacci(n):
    fib = [0, 1]
    while len(fib) < n:
        fib.append(fib[-1] + fib[-2])
    return fib

print(fibonacci(10))  # Output: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
```


---

# 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://training.gitbook.io/python-assignments/function-practice-questions.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.
