
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































Subject: WGU E010 Foundations of Programming (Python) – Python Syntax, Data Types, Control Flow, Functions, Data Structures, File I/O, Exception Handling, Object-Oriented Programming, Comprehensions, Generators, and Debugging Description: This examination is designed for candidates preparing for the WGU E010 Objective Assessment in Foundations of Programming (Python). It assesses applied knowledge of Python syntax and structure, variables and data types, operators and expressions, conditional statements and loops, functions and parameter passing, scope and recursion, lists, tuples, dictionaries, and sets, string manipulation and slicing, file input and output, exception handling, object-oriented programming with classes and inheritance, comprehensions, generators, and debugging. Questions are scenario based and require code tracing, output prediction, and critical decision making consistent with the competencies assessed in the WGU E objective assessment. The exam is structured in three sections of fifty questions each, with four options per question and detailed rationales for every correct answer. SECTION 1: Questions 1 to 50
B) "ght" C) "ghtO" D) "hto" Answer: B Rationale: Slicing is inclusive of the start index and exclusive of the end index. Index 2 is g, index 3 is h, and index 4 is t, while index 5 (O) is excluded.
Rationale: Multiplying a string by an integer repeats the string that many times, concatenating it three times to yield "ababab".
C) A float D) A boolean Answer: B Rationale: input() always returns a string, and the programmer must convert it to the desired type if needed.
Answer: B Rationale: The & operator performs set intersection, returning elements common to both sets, which is {3}.
def greet(name="World"): return "Hello, " + name print(greet()) print(greet("Alice")) What is the output? A) Hello, World Hello, Alice B) Hello, Hello, Alice C) Hello, name Hello, Alice D) An error occurs Answer: A Rationale: The default parameter value "World" is used when no argument is provided, and "Alice" is used when provided.
Rationale: The with statement uses a context manager to guarantee that the file is closed even if an exception occurs.
C) class Child inherits Parent: D) class Child: Parent Answer: A Rationale: Python uses parentheses after the class name to indicate inheritance, such as class Child(Parent):.
Answer: A Rationale: list.sort() sorts the list in place in ascending order by default.
Answer: B Rationale: range(1, 5) generates numbers starting at 1 up to but not including 5, yielding [1, 2, 3, 4].