Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

37. write a for loop that displays the following set of numbers: 0, 10,…

Question

  1. write a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 ... 1000
  2. write a loop that asks the user to enter a number. the loop should iterate 10 times and keep a running total of the numbers entered.
  3. write a nested loop that displays 10 rows of # characters. there should be 15 # characters in each row.

Explanation:

Step1: Write for - loop for first problem

for i in range(0, 1001, 10):
    print(i)

Step2: Write loop for second problem

total = 0
for _ in range(10):
    num = int(input("Enter a number: "))
    total += num
print("The running total is:", total)

Step3: Write nested - loop for third problem

for _ in range(10):
    print('#' * 15)

Answer:

# Problem 37
for i in range(0, 1001, 10):
    print(i)
# Problem 38
total = 0
for _ in range(10):
    num = int(input("Enter a number: "))
    total += num
print("The running total is:", total)
# Problem 39
for _ in range(10):
    print('#' * 15)