Question: Python. I have a simple menu program in Python as below. Could somebody please show me the code to do option 3 which is displaying
Python. I have a simple menu program in Python as below. Could somebody please show me the code to do option 3 which is displaying a palindrome from 0 to 1000? Many thanks
## Show Menu ## print("Calculations") print("1. Calculate the area of a square") print("2. Calculate area of a circle") print("3. Display palindromes up to 1,000")
## Get Input ## option = int(input("Enter an option: ")) print("")
## Take action as per menu selection ## if option == 1: print("**** Area of a square ****") width = input("Enter width of square (cm): ") width_length = int(width); area_square = width_length*width_length; print("The area of a square of",width_length,"cm =",area_square,"cm squared"); elif option == 2: print("**** Area of a circle ****") PI = 3.14159 radius = float(input("Enter radius of circle (cm): ")) area_circle = PI * radius * radius print("The area of a circle of",radius,"cm = ",area_circle,"cm squared"); elif option == 3: print("**** Palindromes ****")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
