Docsity

WGU E010 (FOUNDATION OF PROGRAMMING PYTHON) OBJECTIVE ASSESSMENT ACTUAL FINAL STUDY GUIDE, Exams of Quantitative Techniques

Partial preview of the text

Download WGU E010 (FOUNDATION OF PROGRAMMING PYTHON) OBJECTIVE ASSESSMENT ACTUAL FINAL STUDY GUIDE and more Exams Quantitative Techniques in PDF only on Docsity!

WGU E010 (FOUNDATION OF

PROGRAMMING PYTHON)

OBJECTIVE ASSESSMENT

ACTUAL FINAL STUDY GUIDE

2026/2027 LATEST UPDATE.

1. Which symbol begins a single-line comment in Python?

// (double forward slash) # (pound symbol)

  • (asterisk)

% (percent symbol)✔✔ Correct answer # (pound symbol)

2. Which data type is the value 3.14 in Python? Integer

Float String Boolean✔✔ Correct answer Float

3. In Python, what must follow the in keyword in a for loop? A condition

An iterable object A number A variable name✔✔ Correct answer An iterable object

4. Which type of loop is designed for iterating a specific number of times? while loop

for loop infinite loop do-while loop✔✔ Correct answer for loop

5. Which components are required in every Python while loop? A condition and an

indented code block A variable and a return statement A counter and a break statement An iterator and a list✔✔ Correct answer A condition and an indented code block

6. Which keyword is used to exit a loop prematurely in Python? return

break stop end✔✔ Correct answer break

7. In the code for item in my_list✔✔ Correct answer, what does item represent? The

index of the current element

13. Which terminal command is used to navigate to a different directory before running a Python script?

move goto cd nav✔✔ Correct answer cd

14. Which tool is used to execute Python code line-by-line interactively within a terminal?

Python shell Text editor File explorer Debugger✔✔ Correct answer Python shell

15. A program processes file names and extracts the last 3 characters repre-senting the file extension. For

example, files 'document.pdf' and 'image.png' would return 'pdf' and 'png', respectively. Which slicing approach would work for either of the provided files? filename[✔✔ Correct answer9] filename[9✔✔ Correct answer] filename[-3✔✔ Correct answer] filename[✔✔ Correct answer-3]✔✔ Correct answer filename[-3✔✔ Correct answer]

16. Which index position is returned when the string method .find('python') is applied to the string 'learning

python programming'? 8

9

1

2 ✔✔ Correct answer 9

17. Complete the function add_item(numeric_list, new_number) that takes a list of numbers and a new

number, and returns a new list that appends the new number to the end of the list. For example, add_item([1, 2, 3], 4) should return [1, 2, 3, 4].

def add_item(numeric_list, new_number)✔✔ Correct answer

TODO✔✔ Correct answer Add new_number to the end of the list and return the list # Example

✔✔ Correct answer add_item([1, 2, 3], 4) should return [1, 2, 3, 4]

pass✔✔ Correct answer def add_item(numeric_list, new_number)✔✔

Correct answer numeric_list.append(new_number) return numeric_list

18. 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"✔✔ Correct answer 85, "Bob"✔✔ Correct answer 90}, "Alice", 95) should

return

{"Alice"✔✔ Correct answer 95, "Bob"✔✔ Correct answer 90}.

def update_grade(grades, student, new_grade)✔✔ Correct answer

TODO✔✔ Correct answer Update the student's grade and return the dictionary

Example✔✔ Correct answer update_grade({"Alice"✔✔ Correct answer 85, "Bob"✔✔ Correct answer 90}, "Alice", 95)

should return {"Alice"✔✔ Correct answer 95, "Bob"✔✔

Correct answer 90} pass✔✔ Correct answer def update_grade(grades,

student, new_grade)✔✔ Correct answer

grades[student] = new_grade return grades

19. Which for loop correctly iterates through a list of student names?

for name in ['Alice', 'Bob', 'Carol']✔✔ Correct answer

for name with ['Alice', 'Bob', 'Carol']✔✔ Correct answer

for name from ['Alice', 'Bob', 'Carol']✔✔ Correct answer

for name = ['Alice', 'Bob', 'Carol']✔✔ Correct answer for name in ['Alice', 'Bob', 'Carol']✔✔ Correct answer

20. Which loop structure processes every individual item in a list called grades?

while len(grades) > 0✔✔ Correct

answer for grade in grades✔✔

21. A program needs to display only positive, non-zero numbers from a list containing a mixture of integer

and decimal values.

Which conditional statement should be placed inside the loop?

if number > 0✔✔ Correct answer

if number != 0✔✔ Correct answer

if number < 0✔✔ Correct answer

if number >= 1 ✔✔ Correct answer if number > 0✔✔ Correct answer

22. Complete the function double_number(num) that takes one number para- meter and returns double that

number.

For example, double_number(5) should return 10.

def double_number(num)✔✔ Correct answer

TODO✔✔ Correct answer Return double the input number

Example✔✔ Correct answer double_number(5) should return 10 pass✔✔

Correct answer def double_number(num)✔✔ Correct answer return num * 2

23. 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)✔✔ Correct answer

TODO✔✔ Correct answer Add a default value of "World" to the name parameter return "Hello "

  • name✔✔ Correct answer def greet_with_default(name="World")✔✔ Correct answer return "Hello " + name

24. Complete the function is_positive(number) that returns True if the number is greater than 0, and False

otherwise.

def is_positive(number)✔✔ Correct answer

TODO✔✔ Correct answer Return True if number > 0, False otherwise

pass✔✔ Correct answer def password_strength(password)✔✔ Correct answer

if len(password) < 8✔✔ Correct answer

return "Weak"

has_letter = False has_number = False

for char in password✔✔ Correct answer

if char.isalpha()✔✔ Correct answer

has_letter = True elif char.isdigit()✔✔ Correct answer has_number = True

if has_letter and has_number✔✔ Correct answer

return "Strong" else✔✔

Correct answer return "Weak"

27. Write a complete function convert_temperature(celsius) that converts Cel-sius to Fahrenheit using the

formula✔✔ Correct answer F = C * 9/5 + 32.

For example, convert_temperature(0) should return 32.0. def convert_temperature(celsius)✔✔ Correct answer

TODO✔✔ Correct answer Convert Celsius to Fahrenheit using F = C * 9/5 + 32

pass✔✔ Correct answer def convert_temperature(celsius)✔✔ Correct answer

return celsius * 9 / 5 + 32

28. Fix the indexing error in this function that should return the last character of a string.

def get_last_character(text)✔✔ Correct answer

return text[len(text)]✔✔ Correct answer def get_last_character(text)✔✔

Correct answer return text[-1]

Tip✔✔ Correct answer Correctly returning the larger of two numbers using if-else You can use

either approach✔✔ Correct answer

1 Us iãn g a < b✔✔

Correct answer if a < b✔✔ Correct answer return b else✔✔ Correct answer

return a

2 Us iãn g a > b✔✔ Correctanswer

if a > b✔✔ Correct answer

return a else ✔✔ Correct answer return b

Key point✔✔ Correct answer The if condition and the corresponding return statements must align so the larger number is returned. Swapping the comparison requires

swapping the return values accordingly.