5.20 (Ch 5) HW: Output range with increment of 10
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
Then the output is: 15 -5 5 15 25
Ex: If the second integer is less than the first as in 20 5, the output is: Second integer can't be less than the first.
For coding simplicity, output a space after every integer, including the last.
Code:
def main():
a=int(input()) #reading input number 1 from console
from user
b=int(input()) #reading input number 2 from console
from user
if a>b: #Checking whether first number is grater
than second or not
print("Second integer can't be
lesser than the first")
while a<=b:
print(a,end=" ") #printing number
until a is less than b where a is incremented by 10 every
time
a=a+10 #incrementing number by
10
if __name__ == '__main__':
main()
Indendation:
Sample i/o:
Explanation:
As given in requirements a method was written by name main. In main two numbers are taken as input from the user using console. if the number 1 is greater than number 2 then the message "Second integer can't be lesser than the first" is printed on to the screen. if number 1 is less than number 2, then in each iteration a is printed separated by a space and a is incremented by 10. To run the program use "python main.py", after saving the code in main.py file.
num_1 = int(input())
num_2 = int(input())
if num_1 > num_2:
print("Second integer can't be less than the first.", end='')
for x in range(num_1, num_2+1, 10):
print('{} '.format(x), end='')
print('')
num_1 = int(input())
num_2 = int(input())
if num_1 > num_2:
print("Second integer can't be less than the first.", end='')
for x in range(num_1, num_2+1, 5):
print('{} '.format(x), end='')
print('')
Write a program whose input is two integers, and whose output is the first integer
3.16 LAB: Output range with increment of 10 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: 20 5 the output is: Second integer can't be less than...
5.13 LAB: Output range with increment of 10 5.13 LAB: Output range with increment of 10 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 20 5, the output...
IN JAVA Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value. Assume that the list will always contain fewer than 20 integers. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75...
*Coral Language* Write a program that first gets a list of six integers from input. The first five values are the integer list. The last value is the upper threshold. Then output all integers less than or equal to the threshold value. Ex: If the input is 50 60 140 200 75 100, the output is: 50 60 75 For coding simplicity, follow every output value by a space, including the last one. Such functionality is common on sites like...
Coral Language Please to thanks Write a program that first gets a list of 5 integers from input. Then, get another value from the input, and output all integers less than or equal to that value. Ex: If the input is 50 60 140 200 75 100, the output is: 50 60 75 For coding simplicity, follow every output value by a space, including the last one. Then, output a newline. Such functionality is common on sites like Amazon, where...
Write a program whose input is two integers and whose output is the two integers swapped. Write in C language 7.3 LAB: Swapping variables Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 38 then the output is: 83 Your program must define and call a function. SwapValues returns the two values in swapped order. void SwapValues(int* userVali, int* userVal2) ACRIVITY 7.3.1: LAB: Swapping variables 0/10 ] main.c...
Write a program that first gets a list of integers from the input and adds them to an array. The input begins with an integer indicating the number of integers that follow (Your program should work for any size of the array). Then, get the last value from the input, and output all integers less than or equal to that value by iterating through the array. Ex: If the input is: Enter the number of integers: 5 Enter integer 1:...
Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75 The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75....
Please draw a flow chart for each method please and thank you. Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Assume that the list will always contain less than 20 integers. Ex: If the input is: 5 50 60 140 200 75 100 the...
Coral 5.1. Write a program whose inputs are three integers, and whose output is the largest of the three values. Ex: If the input is 7 15 3, the output is: 15 Please provide the answer in Coral with proper line spacing/format.