Programming Functions Quiz

Programming Functions Quiz

1st Grade

30 Qs

quiz-placeholder

Similar activities

array pointer

array pointer

1st Grade

29 Qs

PS Unit 4 Iteration Quiz Review

PS Unit 4 Iteration Quiz Review

1st Grade - Professional Development

30 Qs

đứa nào dưới tb tao đập

đứa nào dưới tb tao đập

1st - 5th Grade

35 Qs

C basics

C basics

1st - 4th Grade

25 Qs

Pemrograman 2

Pemrograman 2

1st Grade

25 Qs

Python

Python

KG - Professional Development

35 Qs

Introduction to Python

Introduction to Python

KG - University

25 Qs

Javascript

Javascript

1st - 5th Grade

25 Qs

Programming Functions Quiz

Programming Functions Quiz

Assessment

Quiz

Computers

1st Grade

Medium

Created by

Adham Elmuntser

Used 1+ times

FREE Resource

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the function call greet("Bob") if the function is defined as def greet(name="Guest"): print(f"Hello, {name}!")

Hello, Bob!

Hello, Guest!

Syntax Error

Hello, Alice!

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements correctly defines a function that returns the square of its argument?

def square(x): return x to the power of 2

def square(x): return x + x

def square(x): return x ** 2

def square(x): return x - x

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of check_even_odd(4) if check_even_odd is defined as def check_even_odd(number): if number % 2 == 0: print(f"{number} is even.") else: print(f"{number} is odd.")?

4 is odd.

4 is even.

Syntax Error

None

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following functions correctly calculates the factorial of a number n?

def factorial(n): return n * (n-1)

def factorial(n): for i in range(1, n + 1): n *= i return n

def factorial(n): result = 1 for i in range(1, n + 1): result *= i return result

def factorial(n): result = 1 for i in range(n): result *= i return result

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In the function def add_numbers(a, b): return a + b, what will be the output of print(add_numbers(2, 3))?

23

5

TypeError

6

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the function call reverse_string("Python") if the function is defined as def reverse_string(s): return s[::-1]?

nohtyP

Python

Syntax Error

Pnohty

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If count_vowels("Hello World") is called, what will be the output given the function def count_vowels(s): vowels = "aeiouAEIOU" count = 0 for char in s: if char in vowels: count += 1 return count?

2

3

4

5

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?