Docsity

Wgu d335 oa introduction to programming in python obje, Exams of Programming Languages

Toggle sidebar
bg1
Wgu d335 oa introduction to programming in python objective
assessment actual questions with verified answers new 2026-2027
update
SECTION 1: Python Fundamentals & Syntax
Question 1
A program consists of which three basic instruction types?
A) Read, Write, Execute
B) Input, Process, Output
C) Compile, Link, Run
D) Define, Call, Return
Correct Answer: B - Input, Process, Output
Rationale: Every program follows the IPO model: it takes input (from
keyboard, file, etc.), processes that data (computations, logic), and
produces output (to screen, file, etc.) .
Question 2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Wgu d335 oa introduction to programming in python obje and more Exams Programming Languages in PDF only on Docsity!

Wgu d335 oa introduction to programming in python objective assessment actual questions with verified answers new 2026- 2027 update SECTION 1: Python Fundamentals & Syntax Question 1 A program consists of which three basic instruction types? A) Read, Write, Execute B) Input, Process, Output C) Compile, Link, Run D) Define, Call, Return Correct Answer: B - Input, Process, Output Rationale: Every program follows the IPO model: it takes input (from keyboard, file, etc.), processes that data (computations, logic), and produces output (to screen, file, etc.). Question 2

What is a variable in Python? A) A fixed value that cannot change B) A named reference to a value stored in memory C) A type of loop structure D) A function that prints output Correct Answer: B - A named reference to a value stored in memory Rationale: A variable is a named item used to hold a value. It acts as a reference or label that points to an object in memory. Variables can be reassigned to different values. Question 3 What is an algorithm? A) A type of Python data structure B) A sequence of instructions that solves a problem C) A built-in Python function

Question 5 How do you denote a comment in Python? A) // comment B) /* comment */ C) # comment or """multi-line comment""" D) Correct Answer: C - # comment or """multi-line comment""" Rationale: Single-line comments begin with #. Multi-line comments can be enclosed in triple quotes (""" or '''). Comments are ignored by the interpreter. Question 6 What is the purpose of the input() function? A) To display output to the screen

B) To get text input from the user C) To convert data types D) To open a file Correct Answer: B - To get text input from the user Rationale: The input() function reads a line of text from the user and returns it as a string. It can optionally display a prompt string. Question 7 What does the type() function return? A) The size of a variable in memory B) The data type of a variable or value C) The value of a variable D) The memory address of a variable Correct Answer: B - The data type of a variable or value

A) A violation of language syntax B) An error that occurs when the program attempts an impossible operation C) A flaw in program logic D) An indentation mistake Correct Answer: B - An error that occurs when the program attempts an impossible operation Rationale: Runtime errors (exceptions) occur during program execution when an operation cannot be completed, such as dividing by zero or attempting an operation on incompatible data types. Question 10 What is a NameError? A) Using an invalid value in an operation B) Trying to use a variable that does not exist C) Improper indentation of code lines

D) Adding an integer to a string Correct Answer: B - Trying to use a variable that does not exist Rationale: A NameError occurs when the interpreter encounters a variable name that hasn't been defined or is out of scope. Question 11 Which of the following is a Python reserved keyword? A) for B) foreach C) loop D) until Correct Answer: A - for Rationale: for is a reserved keyword in Python used for iteration. foreach, loop, and until are not Python keywords.

C) D) Correct Answer: B - Rationale: The value 5 is an integer literal in Python. The type() function returns the data type of the object passed to it. Python does not use a generic number type for integers. Question 14 Which data type stores text? A) int B) float C) str D) bool Correct Answer: C - str

Rationale: The str (string) data type is used to store text in Python. Strings can be created using single quotes, double quotes, or triple quotes. Question 15 What is the result of "Hello" + " " + "World" in Python? A) HelloWorld B) Hello World C) Hello + World D) Error Correct Answer: B - Hello World Rationale: The + operator concatenates strings in Python. "Hello" + " " + "World" produces "Hello World". Question 16 What will this code output? print("5" + "3")

Correct Answer: C - _totalCost Rationale: Python variable names may contain letters, numbers, and underscores, but cannot start with a number or contain spaces or hyphens. _totalCost follows all naming rules. class is a reserved keyword and cannot be used as an identifier. Question 18 What does the len() function do in Python? A) Returns the length of a string or sequence B) Converts a string to lowercase C) Rounds a number to the nearest integer D) Returns the absolute value of a number Correct Answer: A - Returns the length of a string or sequence Rationale: The len() function returns the number of items in a container (string, list, tuple, dictionary, etc.).

Question 19 What is the output of print(5 + 3 * 2)? A) 16 B) 11 C) 13 D) 10 Correct Answer: B - 11 Rationale: Python follows standard operator precedence: multiplication before addition. 3 * 2 is evaluated first, giving 6, then 5 + 6 equals 11. Question 20 Which operator performs exponentiation? A) ^ B) * C) **

Rationale: The int() function converts a value to an integer. For example, int("123") returns 123. The string must represent a valid integer. Question 22 What does the input() function always return? A) An integer B) A float C) A string D) A Boolean Correct Answer: C - A string Rationale: The input() function always returns the user's input as a string. If numeric input is needed, it must be converted using int() or float(). Question 23 Which operator returns the remainder of division?

A) /

B) //

C) %

D) **

Correct Answer: C - % Rationale: The modulo operator % returns the remainder after division. For example, 10 % 3 returns 1. This operator is often used to check for even or odd numbers. Question 24 What is the output of print(2 ** 3)? A) 6 B) 8 C) 9 D) 5

SECTION 2: Data Types & Structures Question 26 What is the data type of the variable x after x = 5? A) String B) Integer C) Float D) Boolean Correct Answer: B - Integer Rationale: In Python, a numeric value without a decimal point is classified as an int (integer). Question 27 What is the output of print(3 + 2.5)? A) 5 B) 5.

C) 6

D) Error Correct Answer: B - 5. Rationale: Python automatically performs implicit type conversion. The integer 3 is converted to a float to perform the addition, resulting in a float value of 5.. Question 28 What is the output of print(type(3.14))? A) B) C) float D) 3. Correct Answer: B -