Write a program to calculate area of square in python?
Answers
choice = "Yes"
while choice == "Yes":
s = float(input("Enter the length of a side of the square: "))
area = s**2
print(area, "is the area of the square.")
print()
choice = input("Would you like to go again? [Yes/No]: ")
print()
print("Thank you!")
I've used a while loop in this case, if the user would like to go again.
A while loop is an iteration control statement, that does repeated checking for every situation. It mostly depends upon Boolean values and proceeds accordingly.
choice = "Yes"
while choice == "Yes":
s = float(input("Enter the length of a side of the square: "))
area = s2
print(area, "is the area of the square.")
print()
choice = input("Would you like to go again? [Yes/No]: ")
print()
print("Thank you!")
I've used a while loo
A while loop is an iteration control statement, that does repeated checking for every situation. It mostly depends upon Boolean values and proceeds accordingly.