+ 1
Please help me with this code.
# To calculate the Area and the Perimetre of a rectangle. d = str(input("Type A for Area and P for Perimetre: ")) d = d.upper() if d != "A" or "P": print("You have Entered a wrong letter.") exit() b = float(input("Enter the Length in cm (in cm): ")) c = float(input("Enter the Breath in cm (in cm): ")) if d == "A": print("Area of the rectangle is: ", (b * c), "cm^2") elif d == "P": print("Perimetre of the rectangle is: ", (2 * (b + c)), "cm")
2 Respostas
+ 3
Corrected !!
#To calculate the Area and the Perimetre of a rectangle.
d = input("Type A for Area and P for Perimetre: ")
d = d.upper()
if (d != "A") and (d != "P"):
print("You have Entered a wrong letter.")
exit()
b = float(input("Enter the Length in cm (in cm): "))
c = float(input("Enter the Breath in cm (in cm): "))
if d == "A":
print("Area of the rectangle is: ", (b * c), "cm^2")
elif d == "P":
print("Perimetre of the rectangle is: ", (2 * (b + c)), "cm")
+ 1
thankyou very much 丹ⓨㄩک廾