How?i = 3 while i >=0: print(i) i = i - 1 then the answer is 4??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How?i = 3 while i >=0: print(i) i = i - 1 then the answer is 4???

i'm don't understand does the answer must be 3?

11th Sep 2016, 7:43 AM
Tristan Aryo
Tristan Aryo - avatar
19 Answers
+ 5
the answer is 4 because it says while i is geater than or equals 0 (i >= 0)
11th Sep 2016, 9:08 AM
DoubleD
+ 2
output must be: 3 2 1 0
22nd Jan 2017, 6:08 PM
Neha Pede
+ 2
Answer 4 and out put should be 3 2 1 0 Like this 4times
12th Feb 2017, 8:14 AM
chetan
chetan - avatar
+ 2
I = 3 comment: you have let I to be 3. while I >= 0 : (u have set while condition to be true in this line) print(I) I =I - 1 (this will keep printing I starting from 3 till it reaches 0 I.e decreases by -1.) output: first iteration. it will print 3. 2nd iteration. it will print 2. I.e decreases by -1 3rd iteration. it will print 1. 4th iteration. it will print 0 and end d program
14th Feb 2017, 9:46 AM
Hammed Quadri
Hammed Quadri - avatar
+ 1
don't understand either couse i=i-1 this means 0 - 1=-1 which is not satisfied i>=0 so my answer is 3
11th Dec 2016, 2:08 AM
Yohannes Azeze
Yohannes Azeze - avatar
+ 1
On the other hand, when you code; I = 3 while I >= 0: #You have set while condition to be true print(I) The output is; 3 3 3 3 3 3 3 3 3 3 3 3 . . . # Looping forever because the while condition set to be true, until you interrupt the program by pressing Ctrl+C on your Keyboard.
24th Apr 2017, 5:32 AM
Brian Sitali
Brian Sitali - avatar
+ 1
4 is the answer
24th Jan 2020, 5:20 AM
THILAGAVATHI J SACAS
THILAGAVATHI J SACAS - avatar
+ 1
How many numbers does this code print? i = 3 while i>=0: print(i) i = i - 1 anser 4
19th May 2020, 4:11 AM
Abdelhadi Mastakou
Abdelhadi Mastakou - avatar
+ 1
I=3 While i>=0: Print(i) I=i-1 Answer: 3 2 1 0 It repeats four times.because se should start from 4-1=3 3-1=2 2-1=1 1-1=0 And Bread ejecution
6th Aug 2021, 10:26 AM
HmaimiCraft 82
HmaimiCraft 82 - avatar
0
The answer is 4
29th Dec 2020, 1:24 PM
Coder Ayush
Coder Ayush - avatar
0
The question is the how many iterate the loop so the answer is - 4 times
23rd Mar 2021, 5:25 PM
Alauddin Mallick
Alauddin Mallick - avatar
0
answer = 4
27th Aug 2021, 1:23 PM
PRINCE KUMAR
PRINCE KUMAR - avatar
0
answer is 4
20th Jul 2022, 8:16 AM
Vishnu R
0
its ans is 4
4th Jan 2023, 4:30 PM
Engr.Ayesha Liaqat
Engr.Ayesha Liaqat - avatar
- 1
i = 3 while i <0: i +=1 print(i)
11th Sep 2016, 8:05 AM
Özgür Bildik
Özgür Bildik - avatar
- 1
thx
11th Sep 2016, 9:09 AM
Tristan Aryo
Tristan Aryo - avatar
- 1
i = 3 while i >=0: print(i) i = i - 1 result may be:- 3 2 1 0
21st Jan 2017, 8:59 AM
viraj SHAH
viraj SHAH - avatar
- 1
the question is how many
25th Jan 2017, 7:56 AM
wordfeng
- 1
got really confused,i got my answer to be 3
10th Feb 2017, 2:09 AM
iché
iché - avatar