Function Practice Questions
Write a function that takes two numbers as input and returns their sum.
def add_numbers(num1, num2):
return num1 + num2Write a function that takes a list of numbers as input and returns the maximum value in the list.
def find_max(numbers):
return max(numbers)Write a function that takes a string as input and returns the number of vowels in the string.
def count_vowels(word):
vowels = "aeiou"
count = 0
for char in word:
if char.lower() in vowels:
count += 1
return countWrite 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.
def start_with_vowel(words):
vowels = "aeiou"
result = []
for word in words:
if word[0].lower() in vowels:
result.append(word)
return resultWrite a function that takes a list of numbers as input and returns a new list that contains only the even numbers.
Write a function that takes a string as input and returns the string in reverse order.
Write a function that takes a list of numbers as input and returns the average value of the numbers.
Write a function that takes a string as input and returns a new string that has all the vowels removed.
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.
Write a function that takes a list of strings as input and returns a new list that contains the length of each string.
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.
Write a function that takes a string as input and returns the number of words in the string.
Write a Python function to find the maximum of three numbers.
Write a Python function to reverse a string.
Write a Python function to check if a string is a palindrome.
Write a Python function to calculate the factorial of a number.
Write a Python function to check if a number is prime.
Write a Python function to find the greatest common divisor (GCD) of two numbers.
Write a Python function to convert a string to title case.
Write a Python function to calculate the area of a circle.
Write a Python function to generate a list of all prime numbers up to a given number.
Write a Python function to calculate the Fibonacci sequence up to a given number of terms.
Last updated