Question types

Functions question types

71 questions across 7 question groups — pick any mix to generate a Computer Science paper with step-by-step answer keys.

71
Questions
7
Question groups
5
Question types
Sample Questions

Functions questions

One sample from each question group in this chapter. Select any group above to see the full set with answer keys.

Q 1M.C.Q1 Mark
If a function doesn't have a return statement, which of the following does the function return?
  • A
    int
  • B
    null
  • none
  • D
    An exception is thrown without the return statement

Answer: C.

View full solution
Q 2M.C.Q1 Mark
What is a variable defined inside a function referred to as?
  • A
     A static variable
  • B
    A global variable
  • A local variable
  • D
    An auto variable

Answer: C.

View full solution
Q 3M.C.Q1 Mark
What is a variable defined outside a function referred to as?
  • A
     A static variable
  • A global variable
  • C
    A local variable
  • D
    An auto variable

Answer: B.

View full solution
Q 4M.C.Q1 Mark
What is the output of the functions shown below?min(max(False, -3,-4),2,7)
  • -3
  • B
    -4
  • C
    true
  • D
    0

Answer: A.

View full solution
Q 5M.C.Q1 Mark
What will be the output of the following code?import math
abs(math.sqrt(25))
  • A
    5
  • 5.0
  • C
    Error
  • D
    No output

Answer: B.

View full solution
Q 121 Marks Each1 Mark
Write the function header(declaration) which consist of two parameter one is x and other one is y with its default value "hi".
View full solution
Q 202 Marks Each2 Marks
Write a python function to print the number of the digits in number. The function digit() will take the number as parameter and the number of digits one, two, three or more than three digits.
View full solution
Q 253 Marks Each3 Marks
Write the function definition for the following: (a) A function ADD() accepts two parameters. (b) A function ADD() accepts two parameters and returns a single value. (c) A function Vote_Casting() will accepts age and citizen as parameter returns Boolean value. (d) A function Show () accepts no parameters and returns nothing.
View full solution
Q 265 Marks Each5 Marks
ABC School offered Stream to their students on the basis of following criteria. Programmer wrote the following code.

Maths Science Average Stream_Offered
>=80 >=90 >=90 Medical
>=75 >=85 >=85 Non-Medical
>=75 >=60 >=75 Commerce with Maths
>=60 >=60 >=60 Commerce without Maths
>=50 >=45 >=50 Humanities Stream
Otherwise Vocational Stream

Choose the correct possible option on the basis of following code.

(a) Which Statement will be executed, If a Student scored marks as Maths = 75, Science = 80 and Average = 89.

(i) Statement 1 (ii) Statement 2

(iii) Statement 3 (iv) Statement 4

(b) When a Student is Eligible for Humanities Stream?

(i) Student scored marks as Maths less than 65, Science = 80 and Average = 89.

(ii) Student scored marks as Maths = 75, Science = 80 and Average = 89.

(iii) If a Student scored marks as Maths = 55, Science = 47 and Average = 55.

(iv) If a Student scored marks as Maths = 75, Science = 80 and Average = 89.

(c) Which Statement will be executed, If a Student scored marks as Average = 65, Science = 78 and Maths = 80.

(i) Statement 3 (ii) Statement 4

(iii) Statement 5 (iv) Statement 6

(d) Which Statement will be executed, if a Student Scored marks in Science = 35, Maths = 37 and Average = 41.

(i) Statement 3 (ii) Statement 4

(iii) Statement 5 (iv) Statement 6

(e) Which Statement will be executed, If a Student Scored Science =66 , Maths =64 and Average = 65.

(i) Statement 4 (ii) Statement 5

(iii) Statement 3 (iv) Statement 6

View full solution
Q 275 Marks Each5 Marks
Indian Law Organization is planning to computerized their application form. For registration, organization has setup the rules imposed by Indian Law. Citizen can check their eligibility criteria by providing Nationality, Gender and Age.

On the basis of above code, choose the best appropriate option.

(a) Which statement will be executed if Nationality is Indian, Gender is Male and Age is 19.

(i) Statement 1 (ii) Statement 2

(iii) Statement 3 (iv) Statement 4

(b) Which Statement will be executed, if Nationality is American, Gender is Female and Age is 27.

(i) Statement 1 (ii) Statement 2

(iii) Statement 4 (iv) Statement 5

(c) Which Statement is executed, if Nationality is Indian, Age is 25 and Gender if Female.

(i) Statement 1 (ii) Statement 2

(iii) Statement 3 (iv) Statement 4

(d) Which Statement is executed, if Nationality is Indian, Age is 17 and Gender is Female.

(i) Statement 1 (ii) Statement 2

(iii) Statement 3 (iv) Statement 4

(e) Which statement will be executed if Nationality is Indian, Gender is Male and Age is 29.

(i) Statement 1 (ii) Statement 2

(iii) Statement 3 (iv) Statement 4

View full solution
Q 285 Marks Each5 Marks

The ABC School Management has given a task to Mr. Amit Anand to write the code for the promotion rule/salary increment. He wrote the following code using function. On the basis of code, answer the following question.


(a) Which statement will be executed if Post = “Pgt” and experience = 15?
(i) Statement 1 (ii) Statement 2
(iii) Statement 3 (iv) Statement 4
(b) Which statement will be executed if Post = “Vice Principal” and experience = 15?
(i) Statement 2 (ii) Statement 4
(iii) Statement 6 (iv) Statement 8
(c) Which statement will be executed if Post = “tgt” and experience = 5?
(i) Statement 5 (ii) Statement 6
(iii) Statement 7 (iv) Statement 8
(d) Which statement will be executed if Post = “tgt” and experience = 22?
(i) Statement 5 (ii) Statement 6
(iii) Statement 7 (iv) Statement 8
(e) Which statement will be executed if Post = “Pgt” and experience = 15?
(i) Statement 1 (ii) Statement 2
(iii) Statement 3 (iv) Statement 4
View full solution
Q 294 Marks Each4 Marks
Write python program using function to find the sum of first n terms of the following series:

where n and x have to be input from the user. The function should have two parameter n and x and return the sum of the series.

View full solution
Q 304 Marks Each4 Marks
Write python program using function to find the sum of first n terms of the following series:

where n and x have to be input from the user. The function should have two parameter n and x and return the sum of the series.

View full solution
Q 334 Marks Each4 Marks
Write a menu driven python program using function to do the following: 1. Reverse a Number, 2. Check whether a number is Palindrome or not and 3. To check whether it is Armstrong or not and 4 to exit. Program should continue till the user says 'no'
View full solution

Generate a Functions paper free

Pick question groups from the list above, set marks and difficulty, and export a branded PDF with step-by-step answer keys. First 3 chapters free — no signup.

Download App