
Programming Functions Quiz

Quiz
•
Computers
•
1st Grade
•
Medium
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
Similar Resources on Wayground
30 questions
Scratch Quiz

Quiz
•
1st - 3rd Grade
25 questions
JavaScript

Quiz
•
1st - 10th Grade
25 questions
java basics

Quiz
•
KG - 1st Grade
30 questions
Android Studio

Quiz
•
1st Grade
35 questions
đứa nào dưới tb tao đập

Quiz
•
1st - 5th Grade
25 questions
lesson 26

Quiz
•
1st Grade
30 questions
Excel formula1

Quiz
•
1st Grade
28 questions
php3

Quiz
•
1st Grade
Popular Resources on Wayground
55 questions
CHS Student Handbook 25-26

Quiz
•
9th Grade
18 questions
Writing Launch Day 1

Lesson
•
3rd Grade
10 questions
Chaffey

Quiz
•
9th - 12th Grade
15 questions
PRIDE

Quiz
•
6th - 8th Grade
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
22 questions
6-8 Digital Citizenship Review

Quiz
•
6th - 8th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
PBIS Terrace View

Quiz
•
1st - 5th Grade
20 questions
Subject and predicate in sentences

Quiz
•
1st - 3rd Grade
20 questions
Addition and Subtraction facts

Quiz
•
1st - 3rd Grade
9 questions
Good Citizenship and Responsibility

Interactive video
•
1st - 3rd Grade
20 questions
Number Words Challenge

Quiz
•
1st - 5th Grade
20 questions
Place Value

Quiz
•
KG - 3rd Grade
7 questions
Science Safety

Quiz
•
1st - 2nd Grade
25 questions
Math Review

Quiz
•
1st Grade