Programming Functions Quiz

Programming Functions Quiz

1st Grade

30 Qs

quiz-placeholder

Similar activities

02-Test

02-Test

1st - 5th Grade

26 Qs

CKQT-Scratch - Coding

CKQT-Scratch - Coding

1st - 5th Grade

35 Qs

ms word grade 1 , 2

ms word grade 1 , 2

1st - 2nd Grade

27 Qs

java basics

java basics

KG - 1st Grade

25 Qs

Ujian Pengetahuan Laravel Vidio Part 2-6

Ujian Pengetahuan Laravel Vidio Part 2-6

1st Grade

25 Qs

Sql Quiz

Sql Quiz

1st - 5th Grade

25 Qs

QUIZ XII TKJ

QUIZ XII TKJ

1st Grade

25 Qs

Windows 10 Configuration

Windows 10 Configuration

1st - 10th Grade

35 Qs

Programming Functions Quiz

Programming Functions Quiz

Assessment

Quiz

Computers

1st Grade

Practice Problem

Medium

Created by

Adham Elmuntser

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?