[Type C]Q3. Write a program to have the following functions: 1) A function that takes a number as argument and calculates cube for it. The function does not return a value. If there is no function in the function call, the function should calculate the cube of 2. 2) A function takes two char arguments and returns True if both arguments are equal otherwise False

A function is a set of statements that take inputs, do some specific computation and produces output. 

You can pass data, known as parameters, into a function.

Syntax of function in python:

def function_name(parameters):
	"""docstring"""
	statement(s)

Program code:

Output:

Cube of 2 is 8
Cube of 5 is 125 
False 
True 
False

Basic use of python function is demonstrated in above program.

To view all the lessons in chapter 1: http://computertutor.in/class-12-computer-science/chapter-3/

To view entire class 12 computer science study material: http://computertutor.in/resources/

You cannot copy content of this page