Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In python, Write a program separated with functions, with a main function that randomly generates two integers between 0 and 100. You should then check

In python,

Write a program separated with functions, with a main function 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions