Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

WGU Scripting and Programming Foundations Exam - Topic 4 Question 14 Discussion

Which expression evaluates to 4 if integer y = 3?
D) 11 + y % 5
A) 0 - y / 5.0
B) (1 + y) * 5
C) 11.0 - y / 5

WGU Scripting and Programming Foundations Exam - Topic 4 Question 14 Discussion

Actual exam question for WGU's WGU Scripting and Programming Foundations exam
Question #: 14
Topic #: 4
[All WGU Scripting and Programming Foundations Questions]

Which expression evaluates to 4 if integer y = 3?

Show Suggested Answer Hide Answer
Suggested Answer: D

Comprehensive and Detailed Explanation From Exact Extract:

Given y = 3 (an integer), we need to evaluate each expression to find which yields 4. According to foundational programming principles, operator precedence and type handling (e.g., integer vs. floating-point division) must be considered.

Option A: '0 - y / 5.0.'

Compute: y / 5.0 = 3 / 5.0 = 0.6 (floating-point division due to 5.0).

Then: 0 - 0.6 = -0.6.

Result: -0.6 4. Incorrect.

Option B: '(1 + y) * 5.'

Compute: 1 + y = 1 + 3 = 4.

Then: 4 * 5 = 20.

Result: 20 4. Incorrect.

Option C: '11.0 - y / 5.'

Compute: y / 5 = 3 / 5 = 0 (integer division, as both are integers).

Then: 11.0 - 0 = 11.0.

Result: 11.0 4. Incorrect.

Option D: '11 + y % 5.'

Compute: y % 5 = 3 % 5 = 3 (remainder of 3 5).

Then: 11 + 3 = 14.

Result: 14 4.

Correction Note: None of the options directly evaluate to 4 with y = 3. However, based on standard problem patterns, option D's expression 11 + y % 5 is closest to typical correct answers in similar contexts, but the expected result should be re-evaluated. Assuming a typo in the options or expected result, let's test a likely correct expression:

If the expression were 1 + y % 5:

y % 5 = 3, then 1 + 3 = 4.

This fits, but it's not listed. Since D is the most plausible based on structure, we select it, noting a potential error in the problem.

Answer (Tentative): D (with note that the problem may contain an error, as no option yields exactly 4).

Certiport Scripting and Programming Foundations Study Guide (Section on Operators and Expressions).

Python Documentation: ''Arithmetic Operators'' (https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations).

W3Schools: ''C Operators'' (https://www.w3schools.com/c/c_operators.php).


Contribute your Thoughts:

0/2000 characters
I think option A is definitely not it since 0 - 3 / 5.0 would give a negative number, right?
upvoted 0 times
...
Chantay
5 days ago
I practiced a similar question where we had to evaluate expressions with variables. I feel like option D could be close since y % 5 is 3, but I’m not confident.
upvoted 0 times
...
Rikki
10 days ago
I'm not sure about option C; I remember something about dividing by 5 but can't recall if it would give 4.
upvoted 0 times
...
Devora
15 days ago
I think option B might be the right choice because (1 + 3) * 5 equals 20, but I need to double-check the calculations.
upvoted 0 times
...

Save Cancel