[Type C]Q9. Write a program that generates a series using a function that takes the first and last value of the series and then generates four terms that are equidistant. e.g] If two numbers passed are 1 and 7 then the function returns 1357

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:

[1, 3, 5, 9]
[4, 5, 6, 8] 
[4, 6, 8, 10] 
[1, 3, 5, 7]

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