









































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Ace your WGU E010 Foundations of Programming (Python) exam by mastering core programming concepts including variables, control structures, functions, and data types. This study guide evaluates your ability to write and debug Python code through realistic, hands-on practice questions. It is specifically designed to ensure your success on the objective assessment and build a solid foundation for further programming coursework.
Typology: Exams
1 / 49
This page cannot be seen from the preview
Don't miss anything!










































Ace your WGU E010 Foundations of Programming (Python) exam by mastering core programming concepts including variables, control structures, functions, and data types. This study guide evaluates your ability to write and debug Python code through realistic, hands-on practice questions. It is specifically designed to ensure your success on the objective assessment and build a solid foundation for further programming coursework. Which symbol begins a single-line comment in Python? // (double forward slash)
Which data type is the value 3.14 in Python? Integer Float String Boolean ✓ ✓ ...... ANSWER ....... Float In Python, what must follow the in keyword in a for loop? A condition An iterable object A number A variable name ✓ ✓ ...... ANSWER ....... An iterable object Which type of loop is designed for iterating a specific number of times? while loop for loop infinite loop do-while loop ✓ ✓ ...... ANSWER ....... for loop
Which Python data structure automatically prevents duplicate values from being stored? List Tuple Dictionary Set ✓ ✓ ...... ANSWER ....... Set Which Python data structure cannot be modified after creation? List Dictionary Tuple Set ✓ ✓ ...... ANSWER ....... Tuple What must a developer do to run Python code written in a text editor? Save the file and use a Python interpreter. Press a run button within the editor. Upload the code to a web server.
Convert the code to machine language first. ✓ ✓ ...... ANSWER ....... Save the file and use a Python interpreter. What advantage does an integrated terminal provide compared to using a separate terminal application? Faster code execution speed Access to additional Python libraries Eliminates need to switch between applications Automatic syntax error detection ✓ ✓ ...... ANSWER ....... Eliminates need to switch between applications Which action allows a Python script located in a different folder to be executed in the terminal? Use the edit command to open the script first Move the script to your desktop Use the cd command to navigate to the script's directory Rename the script to match the terminal's path ✓ ✓ ...... ANSWER ....... Use the cd command to navigate to the script's directory
filename[9:] filename[-3:] filename[:-3] ✓ ✓ ...... ANSWER ....... filename[-3:] Which index position is returned when the string method .find('python') is applied to the string 'learning python programming'? 8 9 1 2 ✓ ✓ ...... ANSWER ....... 9 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):
the list
pass ✓ ✓ ...... ANSWER ....... def add_item(numeric_list, new_number): numeric_list.append(new_number) return numeric_list 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",
dictionary
pass ✓ ✓ ...... ANSWER ....... def update_grade(grades, student, new_grade):
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: if number != 0: if number < 0: if number >= 1 ✓ ✓ ...... ANSWER ....... if number > 0: 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):
pass ✓ ✓ ...... ANSWER ....... def double_number(num): return num * 2 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):
parameter return "Hello " + name ✓ ✓ ...... ANSWER ....... def greet_with_default(name="World"): return "Hello " + name Complete the function is_positive(number) that returns True if the number is greater than 0, and False otherwise. def is_positive(number):
For example, password_strength("abc123def") should return "Strong". def password_strength(password):
criteria if len(password) < 8: return "Weak" has_letter = False has_number = False for char in password: if char.isalpha(): has_letter = True elif char.isdigit(): has_number = True
has_number
pass ✓ ✓ ...... ANSWER ....... def password_strength(password): if len(password) < 8: return "Weak" has_letter = False has_number = False for char in password: if char.isalpha(): has_letter = True elif char.isdigit(): has_number = True if has_letter and has_number: return "Strong" else: return "Weak"
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 ✓ ✓ ...... ANSWER ....... def is_even(number): if number % 2 == 0: return True else: return False Fix the logic error in this function that should return the larger of two numbers. def find_maximum(a, b): if a < b: return a else:
return b ✓ ✓ ...... ANSWER ....... def find_maximum(a, b): if a < b: return b else: return a Tip: Correctly returning the larger of two numbers using if- else You can use either approach: 1 ⃣ Using a < b: if a < b: return b else: return a 2 ⃣ Using a > b: if a > b:
"B": int(input()), "C": int(input()) } miles_per_employee = {"A": 15.62, "B":41.85, "C": 32.67} total_miles_traveled = sum(travels[employee] * miles_per_employee[employee] for employee in travels) print(f"Distance: {total_miles_traveled:.2f} miles") Create a solution that accepts an integer input representing any number of ounces. Output the converted total number of tons, pounds, and remaining ounces based on the input ounces value. There are 16 ounces in a pound and 2, pounds in a ton. The solution output should be in the format Tons: value_1 Pounds: value_2 Ounces: value_3 ✓ ✓ ...... ANSWER ....... ounces = int(input()) value_1 = ounces // (16 * 2000) value_2 = (ounces % (16 * 2000)) // 16 value_3 = ounces % 16 print(f"Tons: {value_1}") print(f"Pounds: {value_2}")
print(f"Ounces: {value_3}") Create a solution that accepts an integer input representing the index value for any any of the five elements in the following list: various_data_types = [516, 112.49, True, "meow", ("Western", "Governors", "University"), {"apple": 1, "pear": 5}] Using the built-in function type() and getting its name by using the .name attribute, output data type (e.g., int", "float", "bool", "str") based on the input index value of the list element. The solution output should be in the format Element index_value: data_type ✓ ✓ ...... ANSWER ....... index_value = int(input()) data_type = type(various_data_types[index_value]).name print(f"Element {index_value}: {data_type}") Create a solution that accepts any three integer inputs representing the base (b1, b2) and height (h) measurements of a trapezoid in meters. Output the exact area of the trapezoid in square meters as a float value. The exact area of