# Python/Python Functions MCQS Set 1 Sample Test,Sample questions

1.Define

2.DEF

3.def

4.Def

1..py

2..pym

3..mpy

4..mps

## Question: ` def cal(n1) : What is n1?`

1.Parameter

2.Argument

3.Keyword

4.None of the above

1.local

2.global

3.outer

4.var

1.1

2.2

3.3

4.4

1.input( )

2.tuple( )

3.print( )

4.dictionary( )

## Question: ` The return statement in function is used to _____`

1.return value

2.returns the control to the calling function

3.Both of the above

4.None of the above

1.0,19 b.

2.0,17

3.3,16

4.-3,17

## Question: ` Which of the following function headers is correct?`

1. def cal_si(p=100, r, t=2):

2.def cal_si(p=100, r=8, t):

3. def cal_si(p, r=8, t):

4.def cal_si(p, r=8, t=2):

## Question: ``` Which of the following options can be the output for the following code? import random List=["Delhi","Mumbai","Chennai","Kolkata"] for y in range(4): x = random.randint(1,3) print(List[x],end="#")```

1. Delhi#Mumbai#Chennai#Kolkata#

2. Mumbai#Chennai#Kolkata#Mumbai#

3. Mumbai#Chennai#Kolkata#Mumbai#

4.Mumbai# Mumbai #Chennai # Mumbai

1.[1, 2, 3, 4]

2.[4, 5, 6]

3.[7]

4.7

1.-4

2.-5

3.4

4.5

## Question: ``` Write the output of the following code : import random for i in range(random.randint(2, 2)): print(i)```

1.0 1

2.1 2

3.0 1 2

4.Generate different number

## Question: `A = random._______________([1,2,3,4,5]). Fill in the blank so that â€˜Aâ€™ may have any value from the list.`

1. shuffle

2.choice

3.uniform

4.None of the above

1.3

2.7

3.4

4.any number of

1.List

2.Tuple

3.String

4.Dictionary

## Question: `A Python standard library consists of a number of modules`

1.A Python standard library consists of a number of modules

2.Library and modules are alias of each other.

3.A Module consists of a number of Python standard libraries

4.None of the above

## Question: `A variable that is defined inside any function or a block is known as a ___`

1.Global variable

2.Local variable

3.Function Variable

4. inside variable

## Question: `Aman wants to import only sqrt( ) function of math module. Help him to write the correct code.`

1.import math

2.from math import sqrt

3. import sqrt from math

4.import sqrt

## Question: ```Arrange the following from Simple(small) to Complex(big). Instructions, Functions, Library, Module```

1.Instructions, Functions, Library, Module

2.Functions, Instructions, Library, Module

3.Module, Functions, Instructions, Library

4.Instructions, Functions, Module, Library

## Question: ```Choose the correct answer: def s(n1): print(n1) n2=4 s(n2) Statement A : n1 and n2 have same memory Address Statement B : both n1 and n2 are referring to the same value, so they have same identity```

1.Statement A is True and Statement B is False

2. Statement A is False and Statement B is True

3.Both the statements are True

4.Both the statements are False

## Question: `Choose the correct statement`

1.We can create function with no argument and no return value.

2.We can create function with no argument and with return value(s)

3.We can create function with argument(s) and no return value.

4.All of the above

1. Import math

2.import math

3. import Math

4.Import Math

## Question: `Choose the incorrect statement.`

1.print(pow(2, 3))

2. print(pow(2.3, 3.2))

3.print(pow(2, 3, 2))

4.None of the above

## Question: ```Consider the following code and choose the incorrect statement.: def s(n1): print(id(n1)) n2=4 s(n2) print(id(n2))```

1.Function name is â€˜sâ€™

2.Function â€˜sâ€™ is taking one parameter.

3.Both print statement will print the same value.

4.Both print statement will print different value.

## Question: `Division of large programs into smaller programs. These smaller programs are called ____`

1.Functions

2.Operators

3.logical programs

4.specific programs

## Question: `Function defined to achieve some task as per the programmerâ€™s requirement is called a __`

1.user defined function

2. library function

3. built in functions

4.All the above

1.Inbuilt

2.Library

3. User defined

4.logical

## Question: `Functions which are already defined in python is called a ________`

1. user defined function

2.library functions

3. built in functions

4.Both b and c

## Question: `Functions which do not return any value is called ___`

1.default function

2. zero function

3. void function

4.null function

1.2

2.3

3.5

4.Multiple times

## Question: `In math.ceil(x), what is x here?`

1.An Integer

2.A Floating point number

3. An integer or floating point number

4.None of the above

## Question: `In order to get a list of modules available in Python, we can use the __________ statement:`

1.help(â€œmoduleâ€)

2. list(â€œmoduleâ€)

3.available(â€œmoduleâ€)

4.show(â€œmoduleâ€)

1.2

2.7

3.-2

4.0

## Question: `The function can be called in the program by writing function name followed by ___`

1.[ ]

2.{ }

3.( )

4.None of the above

## Question: `The part of the program where a variable is accessible is known as the __________ of that variable`

1. scope

2.module

3.part

4.None of the above

## Question: `The process of dividing a computer program into separate independent blocks of code with specific functionalities is known as _________.`

1.Programming

2.Modular Programming

3.Modular Programming

4.Step Programming

1. send

2.give

3.return

4.take

## Question: `Use of functions _______________ the size of programs.`

1. increases

2.reduces

3. makes no change in

4.None of the above

1.3 and 30

2. 2 and 30

3. 2 and 29

4.2 and 28

1.5#8#15#4#

2.5#8#5#4#

3. 5#8#15#14#

4.. 5#18#15#4#

1.100 200

2.150 300

3.250 75

4.250 300

1.50#50

2.50#5

3. 50#30

4.5#50#

1.3 5 5

2.5 5 5

3. 5 3 5

4.3 3 5

1. 50

2.0

3.Null

4.None

## Question: ```What will be the possible outcome of the following code: import random X =[1,2,3,4] m = random.randint(0,3) for i in range(m): print (X[i],"--",end=" ")```

1. 1 â€”

2.1 â€” 2 â€”

3.1 â€” 2 â€” 3 â€”

4.All the above

1.rand

2.random

3.randomrange

4.randomrange

## Question: `Which of the following are advantages of using function in program?`

2.It increases reusability.

3.It makes debugging easier.

4.All the above

1. only i

2. i and iii

3. iii and iv

4. i, iii and iv

## Question: `Which of the following function definition header is wrong?`

1.def sum(n1, n2, n = 3):

2. def scan(p1, p2 = 4, p3 = 5):

3.def div(p1=4, p2, p3):

4.def mul(p1, n1, m1):

1.mean( )

2. mode( )

3.median( )

4.sqrt( )

## Question: `Which of the following function return random real number (float) in the range 0.0 to 1.0?`

1.random( )

2.randint( )

3.randrange( )

4.None of the above

1.int( )

2.str( )

3.input( )

4.float( )

1.math

2.random

3.statistics

4.arithmetic

## Question: ```Which of the following is not the scope of variable? ```

1.Local

2.Global

3.Outside

4.None of the above

## Question: `Which of the following is not the type of function argument?`

1.Required argument

2. Keyword argument

3. initial argument

4.default argument

## Question: `Which of the following is the correct way to call a function?`

1.my_func( )

2.def my_func( )

3.return my_func

4.call my_func( )

## Question: `Which of the following method is not included in random module?`

1.Shuffle( )

2.randrange( )

3. randomrange( )

4. uniform( )

1.0

2.100

3.99

4.1

## Question: `Which of the following return floating point number?`

1.print(pow(2, 3))

2.print(pow(2.3, 3.2))

3.print(pow(2, 3, 2))

4.All the above

## Question: `Which of the following statement is a function call?`

1.call sum( )

2.def sum( )

3.sum( )

4.function sum( )

## Question: `Which of the following statement is not true regarding functions?`

1.A function definition begins with â€œdefineâ€

2. A function may or may not have parameters.

3.A function may or may not return value.

4. Function header always ends with a colon (:).

## Question: ```Which of the following statement is outside the function â€œsumâ€? def sum(): a = int(input(â€œEnter numberâ€))#Statement 1 b = int(input(â€œEnter numberâ€)) #Statement 2 s = a + b #Statement 3 print(s) #Statement 4```

1.Statement 1

2. Statement 2

3.Statement 3

4.Both Statement 3 and Statement 4

1. Statement 1

2. Statement 2

3. Statement 3

4. Statement 4

1.Statement1

2.Statement2

3.Statement3

4.Statement4

## Question: ```Which of the following subject will never printed in following code? import random L=["English", "Hindi", "Math", "Science", "SST", "CS", "IP"] for i in range(random.randint(1, 6)): print(L[i])```

1. CS and IP both

2. English

3.IP

4.English and Hindi both

## Question: ```Write the output of : print(abs(-45)) ```

1.45.0

2.-45

3.45

4.None of the above

1.-6

2.6.7

3. -6.7

4.7

1.c

2.o

3.u

4.t

1.A A

2.A A A

3.A A OR A A A

4.Error

## Question: ```Write the output of the following code : import random A=random.randrange(20) print(A)```

1.Any number between 0 to 19 (including both)

2.Any number between 0 to 20 (including both)

3.Any number between 1 to 20 (including both)

4.None of the above

## Question: ```Write the output of the following code : import random print(int(random.random( )))```

1.Any random number less than 1 and greater than 0

2.Always generate 0

3.Always generate 1

4.Shows Error

## Question: ```Write the output of the following code : import random print(int(random.random()*5))```

1.Always generate 0

2.Generate any number between 0 to 4 (including both)

3.Generate any number between 0 to 5 (including both)

4.None of the above

## Question: `Write the output of the following. print(int( ))`

1. Error

2. Any random number

3.0

4.1

1.7 7

2.9 9

3.7 9

4.Error

1.16

2.18

3.27

4.24

1.AmitAmitAmit

2.AmitAmit

3.AnujAnujAnuj

4. AnujAnuj

1.3 3

2.5 3

3.3 1

4.3 2

1.3

2.9

3.12

4.10

1.1

2.0

3.2

4.3

1.2

2.3

3.4

4.Error

1.A B C

2.B C A

3.A B

4.A C B

## Question: ```Write the output of the following: sound() def sound(): print("sound" * 2)```

1.sound

2.soundsound

3.NameError : name â€˜soundâ€™ is not defined

4.SyntaxError: invalid syntax

1.fact( )

2. facto( )

3.factorial( )

4.factor( )

1.Function

2.Datatype

3.Token

4.Operator

## More MCQS

##### Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!