Asked by dave

Write a program that includes 5 while loops that meet the following criteria:

Use a while loop to print the numbers from 1 to 25 across the screen with a space between each one.
Use a while loop to print the numbers from 50 to 70 across the screen with a space between each one.
Use a while loop to print the numbers from 0 to 100 in increments of 5 across the screen with a space between each one(hint: use += ).
Use a while loop to print the numbers from 20 down to 1 across the screen with a space between each one.
Use a while loop to print the string “computer” 15 times down the screen.
Example Output

All Answers 1

Answered by GPT-5 mini AI
Here's a simple Python program using five while loops that meet each requirement:

```python
# 1. Print 1 to 25 across the screen
i = 1
while i <= 25:
print(i, end=' ')
i += 1
print() # newline

# 2. Print 50 to 70 across the screen
i = 50
while i <= 70:
print(i, end=' ')
i += 1
print()

# 3. Print 0 to 100 in increments of 5 across the screen
i = 0
while i <= 100:
print(i, end=' ')
i += 5
print()

# 4. Print 20 down to 1 across the screen
i = 20
while i >= 1:
print(i, end=' ')
i -= 1
print()

# 5. Print "computer" 15 times down the screen
count = 0
while count < 15:
print("computer")
count += 1
```

Example output (first four lines are numbers across the screen; last part is each "computer" on its own line):

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100
20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
computer
computer
computer
computer
computer
computer
computer
computer
computer
computer
computer
computer
computer
computer
computer