Computer Science, asked by saumitraverma04, 1 year ago

Write ai python program


AbhijithPrakash: AI??

Answers

Answered by Equestriadash
9

choice = "Yes"

while choice == "Yes":

   print("Given below are a list of shapes.")

   print("1. Rectangle", "2. Circle", "3. Square", "4. Triangle", sep = "\n")

   print("Choose a shape.")

   shape = int(input("Enter the choice of shape: "))

   if shape == 1:

       print("Would you like to find the area or perimeter?")

       ap = input()

       if ap == "Area":

           x = float(input("Enter the length: "))

           y = float(input("Enter the breadth: "))

           area = x*y

           print(x*y, "is the area is the square.")

       elif ap == "Perimeter":

           x = float(input("Enter the length: "))

           y = float(input("Enter the breadth: "))

           pm = 2*(x + y)

           print(pm, "is the perimeter of the square.")

   elif shape == 2:

       print("Would you like to find the area or perimeter?")

       ap = input()

       if ap == "Area":

           x = float(input("Enter the radius of the circle: "))

           area = 3.14*x**2

           print(area, "is the area of the circle.")

       elif ap == "Perimeter":

           x = float(input("Enter the radius of the circle: "))

           pm = 2*3.14*x

           print(pm, "is the perimeter of the circle.")

   elif shape == 3:

       print("Would you like to find the area or perimeter?")

       ap = input()

       if ap == "Area":

           x = float(input("Enter the length: "))

           area = x**2

       elif ap == "Perimeter":

           x = float(input("Enter the length: "))

           pm = 4*x

           print(pm, "is the perimeter of the square.")

   elif shape == 4:

       print("Would you like to find the area or perimeter?")

       if ap == "Area":

           x = float(input("Enter the base: "))

           y = float(input("Enter the height: "))

           area = 1/2*x*y

           print(area, "is the area of the triangle.")

       elif ap == "Perimeter":

           x = float(input("Enter the length of the 1st side: "))

           y = float(input("Enter the length of the second side: "))

           z = float(input("Enter the length of the third side: "))

           pm = x + y + z

           print(pm, "is the perimeter of the triangle.")

   print()

   print("Would you like to go again?")

   print("Yes/No")

   choice = input()

Answered by BeautifulWitch
1

Answer:

# User inputs the string and it gets stored in variable str

str = input("Enter a string: ")

# counter variable to count the character in a string

counter = 0

for s in str:

counter = counter+1

print("Length of the input string is:", counter)

Explanation:

Hope this helps you ✌️

Attachments:
Similar questions