To Documents

Python/JavaScript Control Structure Dictionary

Name Python JavaScript
If..else if n == 1:
    s = "one"

elif n == 2:
  s = "two"

else:
  s = "many"
if (n == 1) {
   s = "one";
}
else if(n == 2) {
   s = "two";
}
else
{
   s = "many";
}
While n = 1
sum = 0.0
while n <= 100:
    sum = sum + n
 
n = 1;
sum = 0.0;
while(n <= 100) {
   sum = sum + n;
   n = n + 1
}
For sum = 0.0
for n in range(1, 101):
    sum = sum + n
 
sum = 0.0;
for(int n = 1; n < 101; n++) {
   sum = sum + n;
   n = n + 1;
}