Answer to Question #240482 in Python for Isabel Cortez

Question #240482

Activity #2 – Smallest and Divisibility


Create a program that will accept 3 integers from the user. Then the program

will print the smallest integer.

The program will also check if the average of the 3 numbers are divisible by 2, 3,

4 and 5. Each divisibility check will output either “The average is divisible by X” or

“The average is not divisible by X”. Each output is separated by a new line.

If the average is not divisible by 2, 3, 4 and 5 the program must output “The

average is not divisible by 2, 3, 4 and 5”.


Sample Run:


Sample Run A

Enter first value: 2

Enter second value: 5

Enter third value: 9

Smallest value is 2

The average is nor divisible by 2

The average is not divisible by 3

The average is not divisible by 4

The average is divisible by 5


Sample Run B

Enter first value: 13

Enter second value: 14

Enter third value: 13

Smallest value is 13

The average is not divisible by 2, 3, 4 and 5



1
Expert's answer
2021-09-22T23:49:29-0400
f=int(input("Enter the First: "))
s=int(input("Enter the Second: "))
t=int(input("Enter the Third: "))
min=0
if f<s and f<t:
    min=f
elif s<f and s<t:
    min=s
else:
    min=t
avr=(f+s+t)/3
print("Average is ",avr)
if f%avr==0:
    print("The average is divisible by ",f)
    print("\nThe average is not divisible by ",s)
    print("\nThe average is not divisible by ",t)


elif s%avr==0:
    print("\n The average is divisible by ",s)
    print("\nThe average is not divisible by ",f)
    print("\nThe average is not divisible by ",min)
    print("\nThe average is not divisible by ",min)



elif t%avr==0:
    print("\nThe average is divisible by ",t)
    print("\nThe average is not divisible by ",s)
    print("\nThe average is not divisible by ",f)
    print("\nThe average is not divisible by ",min)


elif t%min==0:
    print("\nThe average is Not divisible by ",t)
    print("\nThe average is not divisible by ",s)
    print("\nThe average is not divisible by ",f)
    ("\nThe average is divisible by ",min)


else:
    print("\nThe average is not divisible by all")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS