A function is a predefined block of code which is used then programming. It often contains a number of commands and steps.
Here are some of the functions we have met
print()
This function displays the string that is contained in it parenthesis ().
print(‘Hi there, how are you?)
input()
This function displays the string in its parenthesis but allows the user to enter a string that is then returned and assigned to a variable.
age=input(‘What is your age?’)
str()
Converts the contents of its parenthesis to a string
check=input(‘Is your age ‘+str(age))
len()
Outputs the length (number of characters) of a string or the size (number of elements) in an array
print(‘The length of your name is’,len(name))
float()
Converts a value to a floating point number
weight=float(input(‘How many KG do you weight’))
int()
Converts a value to an integer
age=int(input(‘What is your age?’))