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

Python Institute PCEP-30-02 Exam - Topic 3 Question 51 Discussion

Actual exam question for Python Institute's PCEP-30-02 exam
Question #: 51
Topic #: 3
[All PCEP-30-02 Questions]

Which of the following expressions evaluate to a non-zero result? (Select two answers.)

Show Suggested Answer Hide Answer
Suggested Answer: A, B

In Python, the ** operator is used for exponentiation, the / operator is used for floating-point division, and the // operator is used for integer division. The order of operations is parentheses, exponentiation, multiplication/division, and addition/subtraction. Therefore, the expressions can be evaluated as follows:

A) 2 ** 3 / A - 2 = 8 / A - 2 (assuming A is a variable that is not zero or undefined) B. 4 / 2 * * 3 - 2 = 4 / 8 - 2 = 0.5 - 2 = -1.5 C. 1 * * 3 / 4 - 1 = 1 / 4 - 1 = 0.25 - 1 = -0.75 D. 1 * 4 // 2 ** 3 = 4 // 8 = 0

Only expressions A and B evaluate to non-zero results.


Contribute your Thoughts:

0/2000 characters
Tonette
2 days ago
A evaluates to 0, so not that one.
upvoted 0 times
...
Brandee
16 days ago
I’m a bit confused about A; I feel like it could be zero depending on the value of A, but I’m not entirely sure.
upvoted 0 times
...
Truman
21 days ago
I practiced similar questions, and I feel like D might also give a non-zero result, but I can't recall the exact calculations.
upvoted 0 times
...
Arletta
26 days ago
I think option B evaluates to a non-zero result because of the exponentiation, but I need to double-check the order of operations.
upvoted 0 times
...
Galen
1 month ago
I remember something about operator precedence, but I'm not sure if I got it right for these expressions.
upvoted 0 times
...

Save Cancel