[Type C]Q7. Write a function that takes a number n and then returns a randomly generated number having exactly n digits(not starting with zero) e.g] If n is 2 then the function can randomly return 10-99 but 07,02 are not valid two-digit numbers.

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):

Program code:


Random number of digit 3 is 978 
Random number of digit 5 is 63280

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