Question
PYTHONE Write a program that randomly generates two integers between 0 and 100. You should then check if the difference between these two numbers is
PYTHONE
Write a program that randomly generates two integers between 0 and 100. You should then check if the difference between these two numbers is at least 10 and no more than 50 and accordingly print a statement saying This pair of integers is valid or This pair of integers is invalid. Whenever the pair is too close together, replace the larger number with two times that number. Whenever the pair is too far apart, replace the larger number with a third of that number rounded UP (not down). Repeat the process until both numbers are valid.
Once these numbers are valid proceed as per the following:
Print each of the numbers from the smallest (first number) to the largest (second number). Instead of printing the number do the following whenever the specified conditions are satisfied.
Print apple whenever the number is a multiple of 5
Print pen whenever the number is a multiple of 7
Whenever the number contains a 3 print pineapple
These conditions should stack. So the number 35 should print apple pen pineapple in the same line. Sample run:
Two randomly generated integer numbers are 0 and 12
This pair of integers is valid
Output for the valid numbers 0,12:
0
1
2
Pineapple
4
Apple
6
Pen
8
9
Apple
11
12
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started