How can we create function to calculate sum of matrix.
a=10b=20print(id(a))def func(x,y): y=a a=2 print(y) return x+yn1=int(input("Enter no"))n2=int(input("Enter"))print(func(n1,n2))
Dear AllI am using jupyter notebook in Python 3On typing var('x')h(x)=x^2g(x)=xf= Piecewise([[(0,1),h(x)],[(1,2),g(x)]],x)I get following reply.-------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-46-77057750395d> in <module>() 2 __tmp__=var("x"); h = symbolic_expression(x**Integer(2)).function(x) 3 __tmp__=var("x"); g = symbolic_expression(x).function(x) ----> 4 f= Piecewise([[(Integer(0),Integer(1)),h(x)],[(Integer(1),Integer(2)),g(x)]],x) NameError: name 'Piecewise' is not defined Kindly help
13662 visits
Outline:About Functions How to define a function Example for defining a function Calling a function with arguments Calling a function without arguments Return values from a function Indentation in coding Documenting or commenting code How to use docstrings in python function How to write a function circle to return area and perimeter with radius r
About Functions How to define a function Example for defining a function Calling a function with arguments Calling a function without arguments Return values from a function Indentation in coding Documenting or commenting code How to use docstrings in python function How to write a function circle to return area and perimeter with radius r
Show video info
Pre-requisite