C Certs Club
Home
Oracle SAP Microsoft Cisco CompTIA Fortinet Salesforce Nutanix Linux Foundation Amazon View All Vendors →
Login Register

WGU Foundations-of-Programming-Python - Foundations of Programming (Python) - E010 JIV1 Certification Exam

Download Exam View Entire Exam
Page: 1 / 1
Question #1 (Topic: demo questions)

Which components are required in every Python for loop?

A.
A variable, an iterable, and an indented code block
B.
A condition, a counter, and a break statement
C.
A function call, a parameter, and a return value
D.
A list index, a range limit, and a step value 
Correct Answer: A
Explanation:
A Python for loop is used to iterate over an iterable object, such as a list, tuple, string, dictionary, set, or range() object. A basic for loop needs: A loop variable An iterable object An indented code block 
Example: for number in range(3): print(number) In this example: number is the loop variable. range(3) is the iterable. print(number) is the indented code block that runs during each loop iteration. According to the official Python documentation, the for statement is a construct that works with iterable objects. Therefore, the correct answer is A. A variable, an iterable, and an indented code block. 
Question #2 (Topic: demo questions)

What determines which lines of code are executed when the condition is true in a Python if statement?

A.
Lines that are enclosed in parentheses
B.
Lines that share the same indentation level
C.
Lines that end with semicolons
D.
Lines that are enclosed in square brackets 
Correct Answer: B
Explanation:
In Python, indentation determines which statements belong to an if block. Example: temperature = 30 
if temperature > 25: print("It is warm.") print("Drink water.") Both print() statements are executed when the condition is true because they share the same indentation level under the if statement. Python does not use parentheses, semicolons, or square brackets to define the body of an if statement. It uses indentation. Therefore, the correct answer isB. Lines that share the same indentation level. 
Question #3 (Topic: demo questions)

Which type of loop repeatedly checks a condition to determine whether to continue? 

A.
for loop
B.
while loop
C.
range loop
D.
repeat loop 
Correct Answer: B
Explanation:
Awhile looprepeatedly executes a block of code as long as its condition remains true. Example: count = 1 while count <= 3: print(count) count += 1 In this example, Python checks the condition count <= 3 before each loop iteration. If the condition is true, the loop continues. When the condition becomes false, the loop stops. A for loop is usually used to iterate over a sequence, such as a list, string, or range. Python does not have a built-in repeat loop construct. Therefore, the correct answer isB. while loop. 
Question #4 (Topic: demo questions)

Which data type does the expression 5 > 3 evaluate to in Python?

A.
Integer
B.
String
C.
Boolean
D.
Float 
Correct Answer: C
Explanation:
n Python, comparison expressions such as 5 > 3 evaluate to aBooleanvalue. The expression: 5 > 3 checks whether 5 is greater than 3. Since this statement is true, Python returns: True True and False are Boolean values in Python. Therefore, the correct answer isC. Boolean. 
Question #5 (Topic: demo questions)
What must be consistent within a Python code block for the code to run without syntax errors?
A.
 Variable names
B.
 Indentation level
C.
Comment placement
D.
Line length 
Correct Answer: B
Explanation:
In Python, indentation is used to group statements into a code block. A block must have a consistent indentation level so Python can correctly understand which statements belong together. For example: if True: print("Hello") print("World") Both print() statements belong to the same if block because they use the same indentation level. If indentation is inconsistent, Python can raise an IndentationError or TabError. Therefore, the correct answer isB. Indentation level. 
Download Exam
Page: 1 / 1
Next Page