Python Functions Quiz

Python Functions Quiz

University

50 Qs

quiz-placeholder

Similar activities

Circulatory System Quiz

Circulatory System Quiz

6th Grade - University

50 Qs

Noun Phrase

Noun Phrase

University

50 Qs

Words test

Words test

University

53 Qs

Xxx

Xxx

7th Grade - Professional Development

50 Qs

Specialized English - 1

Specialized English - 1

University

49 Qs

Level 3 Final OLT Review 2

Level 3 Final OLT Review 2

University

50 Qs

Quiz về Hệ điều hành

Quiz về Hệ điều hành

University

48 Qs

OS installation

OS installation

University

50 Qs

Python Functions Quiz

Python Functions Quiz

Assessment

Quiz

English

University

Hard

Created by

Srividhya R

FREE Resource

50 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? python Copy def add(a, b): return a + b result = add(5, 3) print(result)

8

5

3

Error

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output? python Copy def multiply(x, y): return x * y result = multiply(4, 3) print(result)

7

12

3

Error

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? python Copy x = 10 def func(): x = 5 return x print(func()) print(x)

5 10

10 5

5 5

10 10

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which function demonstrates recursion? python Copy def factorial(n): if n == 1: return 1 else: return n * factorial(n - 1)

factorial

factorial_recursive

factorial_iteration

None of the above

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? python Copy def func(a, b=3): return a * b result = func(4) print(result)

12

7

4

Error

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements about recursion is true? python Copy def count_down(n): if n == 0: return else: print(n) count_down(n-1)

Recursion will never terminate

Recursion is only valid for integer inputs

The function will print numbers from n down to 1

Recursion terminates before printing

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does this code output? python Copy def test(x): return x + 2 x = test(10) print(x)

10

12

2

Error

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?