asked 31.6k views
2 votes
7.3 Loops: Output range with increment of 10 CHALLENGE ACTIVITY 2010 7.3.1: Output range with increment of 10. Start

Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer. Ex: If the input is -15 30, the output is: -15 -5 5 15 25 Ex: If the second integer is less than the first as in 205, the output is: Second integer can't be less than the first. For coding simplicity, output a space after every integer, including the last Variables 2 // Your solution goes here Not shown when editing.

1 Answer

2 votes

Answer:

# Get input integers

num1 = int(input())

num2 = int(input())

# Check if the second integer is less than the first

if num2 < num1:

print("Second integer can't be less than the first.")

else:

# Generate the sequence of numbers

current_num = num1

while current_num <= num2:

print(current_num, end=' ')

current_num += 10

Step-by-step explanation:

answered
User Jonathan Anctil
by
8.1k points