A function must have as many arguments as defined. If the number of arguments is less or more it will give an error.
def name_function(firstname, lastname):
print(firstname + ” “ + lastname)
name_function(“Raj”, “Kumar”)
Blogger, Engineer & Entrepreneur
A function must have as many arguments as defined. If the number of arguments is less or more it will give an error.
def name_function(firstname, lastname):
print(firstname + ” “ + lastname)
name_function(“Raj”, “Kumar”)
Arguments are passed inside parentheses.
def our_second_function(firstname):
print(firstname + “Raj”)
our_second_function(“Mohan”)
our_second_function(“Narasimha”)
our_second_function(“Krishna”)
There can be as many arguments as required, separated by a comma(,).
def our_first_function():
print(“Hello enterprising people”)our_first_function()
In the above example, def is a keyword.
It is used to define a function.
y = mx + c
y – Dependent variable(DV)
x – Independent variable(IV)
c – constant
dataset = [library alias name].read_csv(‘file.csv’)
x = dataset.iloc[:,:-1].values
y = dataset.iloc[:, -1].values
In the above lines, read_csv and iloc are functions.
[:,:-1] is slicing range of the values.
Syntax
import [library] as []
Basic operations
a=10 b=5 add = a+b sub = a-b mul = a*b div = a/b mod = a%b print(add) print(sub) print(mul) print(div) print(mod)