





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
WGU E010 Foundations of Programming (Python) Practice Assessment | FREQUENTLY TESTED QUESTIONS WITH CORRECT ANSWERS | BRAND NEW!
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!






Which symbol begins a single-line comment in Python? // (double forward slash)
A counter and a break statement An iterator and a list - CORRECT ANSWER โโโ A condition and an indented code block Which keyword is used to exit a loop prematurely in Python? return break stop end - CORRECT ANSWER โโโ break In the code for item in my_list:, what does item represent? The index of the current element The current element being processed The length of the list The entire list - CORRECT ANSWER โโโ The current element being processed Which Python data structure automatically prevents duplicate values from being stored? List Tuple Dictionary Set - CORRECT ANSWER โโโ Set Which Python data structure cannot be modified after creation? List Dictionary Tuple Set - CORRECT 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. - CORRECT ANSWER โโโ Save the file and use a Python interpreter.
filename[:-3] - CORRECT 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 - CORRECT 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):
pass - CORRECT 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", 95) should return {"Alice": 95, "Bob": 90}. def update_grade(grades, student, new_grade):
pass - CORRECT ANSWER โโโ def update_grade(grades, student, new_grade): grades[student] = new_grade return grades
Which for loop correctly iterates through a list of student names? for name in ['Alice', 'Bob', 'Carol']: for name with ['Alice', 'Bob', 'Carol']: for name from ['Alice', 'Bob', 'Carol']: for name = ['Alice', 'Bob', 'Carol'] - CORRECT ANSWER โโโ for name in ['Alice', 'Bob', 'Carol']: Which loop structure processes every individual item in a list called grades? while len(grades) > 0: for grade in grades: for i in range(grades): while grades[0] - CORRECT ANSWER โโโ for grade in grades: 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 - CORRECT 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 - CORRECT ANSWER โโโ def double_number(num):
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
pass - CORRECT 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" 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):
pass - CORRECT ANSWER โโโ def convert_temperature(celsius): return celsius * 9 / 5 + 32 Fix the indexing error in this function that should return the last character of a string. def get_last_character(text): return text[len(text)] - CORRECT ANSWER โโโ def get_last_character(text): return text[-1] 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 - CORRECT 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):