line 4
if salary < 30000
error missing ":"
solution
if salary < 30000:
line 6
tax = salary * 0.2
error is missing identifier for tax
solution add identifier for tax on line 3
tax = 0.0
line 11
error syntax
solution is move tax = salary * 0.4 + 6000 to the right
tax = salary * 0.4 + 6000
a python program for the following output using for loop.
Output:
-13
-7
-1
Answer:
In Python
for i in range(-13,0,6):
print(i)
Explanation:
Required: A program to display the given output
From the program, we observe the following:
The output begins at 13 i.e begin = 13
The output ends at -1 i.e end = 1
And the difference between each output is 6.
i.e. [tex]-1 - (-7) = -7 - (-13) = 6[/tex]
So, the syntax of the for loop is: (begin, end + 1, difference)
The program explanation goes thus:
This iterates through the -13 to 1 with a difference of 6
for i in range(-13,0,6):
This prints the required output
print(i)