Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python Program Use a for loop and a while loop to print the following A. Positiv

ID: 3596489 • Letter: P

Question

Python Program

Use a for loop and a while loop to print the following A. Positive numbers between 2 14 (2,4,6,8,10,12,14) B. Positive negative numbers between-2 -14 (-2,-4,-6,-8,-10,-12,-14) Attach a snipping photo containing source code, and the list of numbers run by both the for loop and the while loop. DO NOT PRINT O WITH YOUR OUTPUT, ONLY (2,4,6,8,10,12,14) You should attach 4 snipping photos. A. Snipping Photo of for loop and while loop generating the same output You will have a minimum of 4 snipping photo or make sure 4 different source code and output examples are visible. Which loop will you use to solve the problem? Briefly explain your reasoning.

Explanation / Answer

# first for loop
x = 2
print("(" + str(x), end="")
for x in range(4, 15, 2):
print("," + str(x),end="")
print(")")

# first while loop
x = 2
print("(" + str(x), end="")
while x <= 14:
print("," + str(x),end="")
x += 2
print(")")


# second for loop
x = -2
print("(" + str(x), end="")
for x in range(-4, -15, -2):
print("," + str(x),end="")
print(")")


# second while loop
x = -2
print("(" + str(x), end="")
while x >= -14:
print("," + str(x),end="")
x -= 2
print(")")

# code link: https://paste.ee/p/jra5c