最新的WGU Foundations of Programming (Python) - E010 JIV1 - Foundations-of-Programming-Python免費考試真題
Which keyword is used to exit a loop prematurely in Python?
正確答案: C
說明:(僅 Fast2test 成員可見)
Which type of loop repeatedly checks a condition to determine whether to continue?
正確答案: C
說明:(僅 Fast2test 成員可見)
How does Jupyter Notebook function as a development environment?
正確答案: A
說明:(僅 Fast2test 成員可見)
Complete the function update_grade(grades, student, new_grade) that takes a grades dictionary, a student name, and a new grade, then updates that student ' s grade and returns the dictionary.
For example, update_grade({ " Alice " : 85, " Bob " : 90}, " Alice " , 95) should return { " Alice " : 95, " Bob
" : 90}.
For example, update_grade({ " Alice " : 85, " Bob " : 90}, " Alice " , 95) should return { " Alice " : 95, " Bob
" : 90}.
正確答案: B
說明:(僅 Fast2test 成員可見)
Write a complete function reverse_string(text) that takes a string and returns it reversed.
For example, reverse_string( " hello " ) should return " olleh " .
def reverse_string(text):
# TODO: Return the reversed string
pass
For example, reverse_string( " hello " ) should return " olleh " .
def reverse_string(text):
# TODO: Return the reversed string
pass
正確答案:
See the Step by Step Solution below in Explanation.
Explanation:
Step 1: The function receives one string parameter named text.
Step 2: Python slicing can be used to reverse a string.
Step 3: The slice [::-1] means start at the end of the string and move backward by one character at a time.
Step 4: Return text[::-1].
Correct code:
def reverse_string(text):
return text[::-1]
Example:
print(reverse_string( " hello " ))
Output:
olleh
Explanation:
Step 1: The function receives one string parameter named text.
Step 2: Python slicing can be used to reverse a string.
Step 3: The slice [::-1] means start at the end of the string and move backward by one character at a time.
Step 4: Return text[::-1].
Correct code:
def reverse_string(text):
return text[::-1]
Example:
print(reverse_string( " hello " ))
Output:
olleh
Which data type does the expression 5 > 3 evaluate to in Python?
正確答案: C
說明:(僅 Fast2test 成員可見)
Which action allows a Python script located in a different folder to be executed in the terminal?
正確答案: D
說明:(僅 Fast2test 成員可見)