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

The area A of a rhombus is defined as A=d1d2/2 where d1 and d2 are the lengths o

ID: 669884 • Letter: T

Question

The area A of a rhombus is defined as A=d1d2/2 where d1 and d2 are the lengths of the two diagonals. Write a script rhomb that first prompts the user for the lengths of the two diagonals. If either is negative number or zero, the script prints an error message. Otherwise If they are both positive, it calls a function rhombarea to return the area of the rhombus, and prints the result.   Write the function also. The lengths of the diagonals, which you can assume are in inches, are passed to the rhombarea function.

Explanation / Answer

def rhombarea (d1, d2):
return ( d1*d2/2 )

d1 = input("Enter 1st diagonal in inches")
d2= input("Enter 2nd diagonal in inches")
if d1 == 0 or d2 == 0 or d1 < 0 or d2 < 0:
print "Input not in correct format"
else:
print rhombarea(d1,d2)

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