0

i don't understand this: for example : a=4 while a=4 print (a) a = a + 1 help me please! !!!!

6th Sep 2016, 12:36 PM
youssef
6 Antworten
+ 2
while you a = 4 programme print a before this code a = a + 1 it's mean a = 4 + 1 before this program finished because a > 4
6th Sep 2016, 12:42 PM
Ришат Султанов
Ришат Султанов - avatar
0
thank you very much
6th Sep 2016, 12:48 PM
youssef
0
a = 4 //assigns 4 to the variable a while a==4 //loop while a is equal to 4 print(a) //print the value of a a = a + 1 //increments a by 1 You declare a variable a equals to 4. a is equal to 4, so you enter the loop. Inside the loop, you print the value of a (which is 4) and increments a by 1 (a is now 5). The loop goes back to the beginning. a is not equal to 4 anymore, so the loop ends.
6th Sep 2016, 2:26 PM
Zen
Zen - avatar
0
thank you😘
6th Sep 2016, 2:43 PM
youssef
0
The General Form: iterator = initial_value while condition_on_the_iterator: do whatever here update the value of the iterator increment/decrement Evaluates as follows: 1- Checks to see if the condition is True - If yes the body gets executed at the end update the iterator and go to 1 - If not (at any iteration), then pass the loop
6th Sep 2016, 9:50 PM
Alansary
0
Note: = is used when assigning a value to a varible == is used to compare for equality In any if condition you must use == not = otherwise your program will raise a syntax error
6th Sep 2016, 9:54 PM
Alansary