Which components are required in every Python for loop?
A. A function call, a parameter, and a return value
B. A variable, an iterable, and an indented code block
C. A list index, a range limit, and a step value
D. A condition, a counter, and a break statement
正解:B
解説: (Pass4Test メンバーにのみ表示されます)
質問 2:
Complete the function double_number(num) that takes one number parameter and returns double that number.
For example, double_number(5) should return 10.
def double_number(num):
# TODO: Return double the input number
# Example: double_number(5) should return 10
pass
正解:
See the Step by Step Solution below in Explanation.
Explanation:
Step 1: The function receives one parameter named num.
Step 2: To double a number, multiply it by 2.
Step 3: The function should return the result using the return statement.
Correct code:
def double_number(num):
return num * 2
Example:
print(double_number(5))
Output:
10
質問 3:
Which data type does the expression 5 > 3 evaluate to in Python?
A. Integer
B. Float
C. Boolean
D. String
正解:C
解説: (Pass4Test メンバーにのみ表示されます)
質問 4:
Which punctuation mark must appear at the end of an if statement line?
A. ; semicolon
B. : colon
C. , comma
D. . period
正解:B
解説: (Pass4Test メンバーにのみ表示されます)
質問 5:
Fix the missing return statement in this function that should return whether a number is even.
def is_even(number):
if number % 2 == 0:
True
else:
False
正解:
See the Step by Step Solution below in Explanation.
Explanation:
Step 1: The expression number % 2 == 0 checks whether the number is even.
Step 2: The original code writes True and False, but it does not return them.
Step 3: A function must use the return statement to send a value back to the caller.
Correct code:
def is_even(number):
if number % 2 == 0:
return True
else:
return False
Simplified correct code:
def is_even(number):
return number % 2 == 0
Example:
print(is_even(4))
print(is_even(7))
Output:
True
False
質問 6:
Which loop structure processes every individual item in a list called grades?
A. while len(grades) > 0:
B. while grades[0]
C. for grade in grades:
D. for i in range(grades):
正解:C
解説: (Pass4Test メンバーにのみ表示されます)
質問 7:
What must a developer do to run Python code written in a text editor?
A. Upload the code to a web server.
B. Convert the code to machine language first.
C. Press a run button within the editor.
D. Save the file and use a Python interpreter.
正解:D
解説: (Pass4Test メンバーにのみ表示されます)
984 お客様のコメント





松原** -
初心者に優しい問題集になっており、無事、試験に合格することができました。本当に助かりました。誠に有難うございます