Question

Question 19 What is the value of test_val after the following code is executed? a = 12 test_val = 6 if a *2 test_val: a = a +
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The right answer is 13

Explanation:

initially, value of a is 12, and value of test_val is 6. The if condition checks if a*2 which is 24 is equal to test_val which is 6. since 24 is not equal to 6, the program will move into else part, which sets test_val to 2*a, which is 24. so after the if block, test_val is 24. But the last line changes the test_val again. it would set a+1, which is 12+1=13 as the new value for test_val. Hence the final value is 13

let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks

Add a comment
Know the answer?
Add Answer to:
Question 19 What is the value of test_val after the following code is executed? a =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT