Programming Functions Quiz

Programming Functions Quiz

1st Grade

30 Qs

quiz-placeholder

Similar activities

ul harian Algo & Pemro

ul harian Algo & Pemro

1st Grade

27 Qs

Computer Coding Basics

Computer Coding Basics

1st - 11th Grade

26 Qs

Grade One ICT

Grade One ICT

1st Grade

25 Qs

Initial HARDWARE

Initial HARDWARE

1st - 2nd Grade

25 Qs

Speed Cup de Ingeniería 2021 (Final)

Speed Cup de Ingeniería 2021 (Final)

1st Grade - University

25 Qs

JQuery

JQuery

1st Grade

25 Qs

tin hoc 11 PT,BT,CL gán

tin hoc 11 PT,BT,CL gán

KG - 1st Grade

26 Qs

BTEC DIT Component 2 Super Quiz

BTEC DIT Component 2 Super Quiz

1st Grade - University

26 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?