Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Python 3 Write a program that will take as input a range of numbers that a

ID: 3684087 • Letter: U

Question

Using Python 3

Write a program that will take as input a range of numbers that allow a skip factor of the user's choice, your program will check if every number in the input is odd or even, and once it finished checking that range of numbers, it will ask the user if they want to enter more numbers. If the user answers 'N', the program quits. If they answer 'Y', the program will ask for another range of numbers. Sample input: Enter a range of numbers. What's your first number? 1 What's your last number? 10 Enter a skip factor: 3 Sample output: Your odd numbers are: 1,7 Your even numbers are: 4, 10 Do you want to enter more numbers (Y/N)? N

Explanation / Answer

#if raw_input() is not working then try input()
while(1):
print "Enter range of number "
first = input("What is your first number? ");
last = input("What is your last number? ");
skip = input("Enter the skip factor: ");

  

list_of_num = []
i = first
while i<=last:
list_of_num.append(i)
i += skip

odd = [i for i in list_of_num if i%2 == 1 ]
even = [i for i in list_of_num if i%2 == 0]

print "Your odd numbers are "
for i in odd:
print i," "

print "Your even numbers are "
for i in even:
print i," "

choice = raw_input("Do you want to enter more numbers? (y/n) ")
if choice!='y' and choice!='Y':
break;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote