0
You are given a program that outputs all the numbers from 0 to 10. Change the code to make it output only the even numbers
x = 0 while x<=10: if (x % 2 = 0) print(x) x += 1 This is my code but it keeps on outputting 0
12 Respostas
+ 10
= is used for assignment of variables and values
== is used for comparisons
And also keep in mind the indentions and colons after if conditions.
if (x % 2 == 0):
print(x)
+ 9
NWACHUKWU PRECIOUS CALEB
There should be == not =
x = 0
while x <= 10:
if x % 2 == 0:
print(x)
x += 1
+ 6
(syntax error) you use ==
Code:
x = 0
while x <= 10:
if x % 2 == 0:
print(x)
x += 1
+ 1
x = 0
while x<=10:
if (x % 2 == 0):
print(x)
x += 1
The if statement needed a : at the end of the parenthesis. Indented everything correctly and the code worked for the solution.
0
x = 0
while x <= 10:
if x % 2 == 0:
print(x)
x += 1
make sure about the indentations that will provide you the error for this
0
X=0
While x<=10:
If x % 2==0:
Print(x)
What do I do next?
0
You are given a program that outputs all the numbers from 0 to 10.
Change the code to make it output only the even numbers.
Solve immediately
0
x = 0
while x <= 10:
if x%2 == 0:
print(str(x))
x += 1
0
x = 0
while x <= 10:
if x % 2 == 0:
print(x)
x += 1
0
Here is the correct answer
x = 0
while x<=10:
if x%2== 0:
print(x)
x+=1
- 1
correct answer
x = 0
while x<=10:
print(x)
x += 2
- 1
x = 0
while x<=10:
print(x)
x+=10
x-=8