Create a program in python to print the negative odd numbers between -30 to -1.
Answers
Answered by
13
Answer:
This is the required program for the question.
print("Odd numbers from -1 to -31 are as follows:")
for i in range(-1,-31,-2):
print(i,end=" ")
Explanation:
- The above loop iterates in the range -1 to -30 . After each iteration, the value of the loop variable is decremented by 2(as two consecutive odd numbers differ by 2).
Syntax of for loop: (Iterating over a range)
for variable in range(x,y,z):
statement1
statement2
here, x is the starting range and y is the ending range and z increments the value in the sequence.
Note: The loop iterates in the range x to y-1 (y is excluded) and for that reason, I wrote -31.
Refer to the attachment.
•••♪
Attachments:
Answered by
0
Answer:
refer to above attachment...
Attachments:
Similar questions