-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ12 two integers output the first integer & subsequent increments of 5.py
More file actions
52 lines (42 loc) · 1.51 KB
/
Copy pathQ12 two integers output the first integer & subsequent increments of 5.py
File metadata and controls
52 lines (42 loc) · 1.51 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Write a program whose input is two integers, and whose output is the first integer and
# subsequent increments of 5 as long as the value is less than or equal to the second integer.
# Ex. If the input is: -15 10 The output is: -15 -10 -5 0 5 10
# Ex. If the second integer is less than the first. The output is: Second integer can't be less than the first.
# start = int(input())
# end = int(input())
# if start > end:
# print("Second integer can't be less than the first.")
# else:
# while start <= end:
# print(start, end=' ') # this keeps getting new line errors when outputting
# start += 5
# start = int(input())
# end = int(input())
#
# if start > end:
# print("Second integer can't be less than the first.")
# else:
# while start <= end:
# print(start, end=' ')
# start += 5
# start = int(input().strip())
# end = int(input().strip())
#
# if start > end:
# print("Second integer can't be less than the first.")
# else:
# while start <= end:
# print(start, end=' ')
# start += 5
# Prints the first integer and subsequent increments of 5 as long as the value is less than or equal to the second integer.
# Args:
# start: The first integer.
# end: The second integer.
def print_increments(start, end):
if start > end:
print("Second integer can't be less than the first.")
else:
for num in range(start, end + 1, 5):
print(num, end=" ") # Print without newline
# Example usage (without input)
print_increments(-15, 10)