Inbuilt Functions

Lesson 15/20 | Study Time: 10 Min

Functions are things we've been indirectly using since the first module.

print( ) and input( ) are some functions that you’ve already used. And these are inbuilt functions.

print("hello world")
input("enter your age")

If you want, you can even create your own function to get some desired output.

Let’s learn some in-built functions in the video mentioned below.


Examples of in-built functions

image.png

round()

  • Round function in python rounds off the decimal value of a number to its nearest integer. For example: round(65.66) = 66.
  • In addition, one can give an input of the specified number of decimals to which the number should be rounded. For example, round(65.66, 1) = 65.7.
  • Its syntax is:
    round(number, ndigits)
    • number - the number to be rounded.
    • ndigits - number of decimal places up to which the given number is rounded; defaults to 0.
round()

sum()

You can perform the addition of a collection of numbers using the sum() function in Python.

sum function

GDPR

When you visit any of our websites, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and manage your preferences. Please note, that blocking some types of cookies may impact your experience of the site and the services we are able to offer.