top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Python Concepts for Data Science: Functions

A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity and higher level of code reuse for your application. Some functions are in built-in and some functions create according to own choice. Built-in-function Any function that is provided as part of a high-level language can be executed by a simple reference with the specification of the argument. Example(sum):


Import Numpy


import numpy as np
a=[1,3,5,7]

Summation


np.sum(a)

Products


np.prod(a)

Creating a function


def cube(x):
result = x*x*x
print(result)

Calling function


cube(5)

0 comments

Recent Posts

See All

Commenti


bottom of page