Welcome to TestSimulate

Pass Your Next Certification Exam Fast!

Everything you need to prepare, learn & pass your certification exam easily.

365 days free updates. First attempt guaranteed success.

WGU Foundations of Programming (Python) - E010 JIV1 (Foundations-of-Programming-Python) Free Practice Test

Question 1
How can the first four characters be extracted from the string ' computer ' ?

Correct Answer: C
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 2
Complete the function is_positive(number) that returns True if the number is greater than 0, and False otherwise.
def is_positive(number):
# TODO: Return True if number > 0, False otherwise
pass
Correct Answer:
See the Step by Step Solution below in Explanation.
Explanation:
Step 1: The function receives one parameter named number.
Step 2: The condition number > 0 checks whether the number is positive.
Step 3: In Python, this comparison already returns either True or False.
Correct code:
def is_positive(number):
return number > 0
Example:
print(is_positive(5))
print(is_positive(-2))
print(is_positive(0))
Output:
True
False
False
Question 3
Modify the function greet_with_default(name) by adding a default value of " World " to the name parameter so it can be called with or without an argument.
def greet_with_default(name):
# TODO: Add a default value of " World " to the name parameter
return " Hello " + name
Correct Answer:
See the Step by Step Solution below in Explanation.
Explanation:
Step 1: A default parameter value allows a function to be called even when no argument is provided.
Step 2: The default value should be added in the function header.
Step 3: The parameter name should have the default value " World " .
Correct code:
def greet_with_default(name= " World " ):
return " Hello " + name
Example:
print(greet_with_default())
print(greet_with_default( " Alice " ))
Output:
Hello World
Hello Alice
Question 4
Which components are required in every Python while loop?

Correct Answer: D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 5
Which Python data structure contains only unique elements and does not support indexing?

Correct Answer: D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 6
Write a complete function convert_temperature(celsius) that converts Celsius to Fahrenheit using the formula:
F = C * 9/5 + 32.
For example, convert_temperature(0) should return 32.0.
def convert_temperature(celsius):
# TODO: Convert Celsius to Fahrenheit using F = C * 9/5 + 32
pass
Correct Answer:
See the Step by Step Solution below in Explanation.
Explanation:
Step 1: The function receives one parameter named celsius.
Step 2: Use the formula:
F = C * 9 / 5 + 32
Step 3: Return the converted Fahrenheit value.
Correct code:
def convert_temperature(celsius):
return celsius * 9 / 5 + 32
Example:
print(convert_temperature(0))
Output:
32.0
Question 7
A program needs to update all values in a list by adding 5 to each number. Which for loop structure accomplishes this task?

Correct Answer: C
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).