CompTIA PenTest+ (PT1-002) — Question 74

Which of the following expressions in Python increase a variable val by one (Choose two.)

Answer options

Correct answer: C, F

Explanation

The correct answers are C and F because 'val=(val+1)' explicitly assigns the value of val increased by one back to val, and 'val+=1' is a shorthand for incrementing val by one. Options A, D, and E are incorrect as they do not represent valid Python syntax for incrementing a variable, and B only returns the value of val without modifying it.