Skip to content

Latest commit

 

History

History

README.md

PYTHON FUNCTIONS

What is a function?

A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result.

Creating a Function

In Python a function is defined using the def keyword:

def my_function():
  print("Hello from a function")

Description

  1. 0-sum.py - Write a function that returns the addition of 2 integers.
  2. 1-power.py - Write a function that returns the power of 2 integers.
  3. 2-temperature.py - Write a function that converts a temperature from Fahrenheit to Celsius.
  4. 3-string.py - Write a Python function called reverse_string that takes a string as input and returns the reverse of that string.
  5. 4-fibonacci.py - Write a function that returns the nth Fibonacci number.
  6. 5-prime.py - Write a function that checks if a number is prime.
  7. 6-password.py - Write a function that validates password.