🔴Final Answer 3/3🔵 but first read process | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

🔴Final Answer 3/3🔵 but first read process

🔴Final Answer 3/3🔵 but first read process x=8 x/=2 y=1 x.times{y+=2} puts y ................................... I understand this: x=4 4.times{1+2} puts y Correct Output Answer 9

23rd Jan 2018, 7:32 PM
Nestor Velez
Nestor Velez - avatar
1 Answer
+ 6
x = 8 # let x = 8 x /= 2 # now divide x by 2 then assign that value to x; so now x = 4 y = 1 # let y = 1 x.times{ y += 2 } # run the code inside the curly braces x amount of times. 4.times { y += 2 } or 4.times { y = y + 2 } # here y += 2 means y = y + 2 1. y += 2 # y = 3 2. y += 3 # y = 5 3. y += 5 # y = 7 4. y += 7 # y = 9 puts y # print y is 9
24th Jan 2018, 2:08 AM
Lord Krishna
Lord Krishna - avatar