Ejemplo n.º 1
0
def main():
    #countrols loop and holds menu choice
    choice = 0

    while choice != QUIT_CHOICE:
        display_menu()
        #get users's choice
        choice = int(input('Enter your choice: '))

        #perform action
        if choice == AREA_CIRCLE_CHOICE:
            radius = float(input('Enter the circles\'s radius: '))
            print('The area is ', circle.area(radius))
        elif choice == CIRCUMFRENCE_CIRCLE_CHOICE:
            radius = float(input('Enter the circle\'s radius: '))
            print('The circumfrence is ', circle.circumfrence(radius))
        elif choice == AREA_RECTANGLE_CHOICE:
            width = float(input('Enter the rectangle\'s width: '))
            length = float(input('Enter the rectangle\'s length: '))
            print('The area is ', rectangle.area(width, length))
        elif choice == PERIMETER_RECTANGLE_CHOICE:
            width = float(input('Enter the rectangle\'s width: '))
            length = float(input('Enter the rectangle\'s length: '))
            print('The area is ', rectangle.perimeter(width, length))
        elif choice == QUIT_CHOICE:
            print('Exit the program')
        else:
            print('Error invalid choice')
Ejemplo n.º 2
0
def main():
    choice = 0

    while choice != QUIT_CHOICE:
        display_menu()
        choice = int(input('Wybierz opcję: '))

        # Wykonanie wybranej akcji.
        if choice == AREA_CIRCLE_CHOICE:
            radius = float(input("Podaj promień okręgu: "))
            print('Pole powierzchni wynosi', circle.area(radius))
        elif choice == CIRCUMFERENCE_CHOICE:
            radius = float(input("Podaj promień okręgu: "))
            print('Obwód wynosi', circle.circumference(radius))
        elif choice == AREA_RECTANGLE_CHOICE:
            width = float(input("Podaj długość prostokąta: "))
            length = float(input("Podaj szerokość prostokąta: "))
            print('Pole powierzchni wynosi', rectangle.area(width, length))
        elif choice == PERIMETER_RECTANGLE_CHOICE:
            width = float(input("Podaj długość prostokąta: "))
            length = float(input("Podaj szerokość prostokąta: "))
            print('Obwód wynosi', rectangle.perimeter(width, length))
        elif choice == QUIT_CHOICE:
            print('Zakończenie działania programu...')
        else:
            print('Błąd: nieprawidłowa opcja.')
Ejemplo n.º 3
0
def main():
    choice = 0

    while choice != QUIT_CHOICE:
        display_menu()
        choice = int(input("Enter your choice: "))

        if choice == AREA_CIRCLE:
            radius = float(input("Enter the radius of the circle: "))
            print("The area of the circle is ", circle.area(radius), "units")

        elif choice == CIRCUMFERENCE_CIRCLE:
            radius = float(input("Enter the radius of the circle: "))
            print("The circumference of the circle is ",
                  circle.circumference(radius), "units")

        elif choice == AREA_RECTANGLE:
            length = float(input("Enter the length of the rectangle: "))
            width = float(input("Ente the width of the rectangle: "))
            print("The area of the rectangle is ",
                  rectangle.area(length, width), "units")

        elif choice == PERIMETER_RECTANGLE:
            length = float(input("Enter the length of the rectangle: "))
            width = float(input("Ente the width of the rectangle: "))
            print("The perimeter of the rectangle is ",
                  rectangle.perimeter(length, width), "units")

        elif choice == QUIT_CHOICE:
            print("Exiting the program.....")
        else:
            print("Error, you selected an invalid choice!!!")
Ejemplo n.º 4
0
def main():
    choice = 0
    while choice != QUIT_CHOICE:
        display_menu()
        choice = int(input('Enter your choice: '))
        if choice == AREA_CIRCLE_CHOICE:
            radius = float(input("Enter the circle's radius: "))
            print('The area is', circle.area(radius))
        elif choice == CIRCUMFERENCE_CHOICE:
            radius = float(input("Enter the circle's radius: "))
            print('The circumference is', \
                  circle.circumference(radius))
        elif choice == AREA_RECTANGLE_CHOICE:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print('The area is', rectangle.area(width, length))
        elif choice == PERIMETER_RECTANGLE_CHOICE:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print('The perimeter is', \
                  rectangle.perimeter(width, length))
        elif choice == QUIT_CHOICE:
            print('EXITING the program...')
        else:
            print('Error: invalid selection.')
Ejemplo n.º 5
0
def main():
    choice = 0

    while choice != QUIT_CHOICE:
        display_menu()

        choice = int(input('Wybierz opcje: '))

        if choice == AREA_CIRCLE_CHOICE:
            promien = float(input('Podaj promien okregu: '))
            print('Pole powierzchni wynosci ', circle.area(promien))
        elif choice == CIRCUMREFERENCE_CHOICE:
            promien = float(input('Podaj promien okregu:'))
            print('Pole powierzchni wynosi ', circle.circumference(promien))
        elif choice == AREA_RECTANGLE_CHOICE:
            dlugosc = float(input('Podaj dlugosc podstawy: '))
            szerokosc = float(input('Podaj szerokosc podstawy '))
            print('Pole powierzchni prostokata wynosi: ',
                  rectangle.area(dlugosc, szerokosc))
        elif choice == PERIMETER_RECTANGLE_CHOICE:
            dlugosc = float(input('Podaj dlugosc podstawy: '))
            szerokosc = float(input('Podaj szerokosc podstawy '))
            print('Obwod wynosi: ', rectangle.perimeter(dlugosc, szerokosc))
        elif choice == QUIT_CHOICE:
            break
        else:
            print('Bledna opcja')
Ejemplo n.º 6
0
def main():
    # Переменная choice управляет циклом
    # и содержит вариант выбора пользователя.
    choice = 0

    while choice != QUIT_CHOICE:
        # Показать меню.
        display_menu()

        # Получить вариант выбора пользователя.
        choice = int(input('Выберите вариант: '))

        # Выполнить выбранное действие.
        if choice == AREA_CIRCLE_CHOICE:
            radius = float(input('Введите радиус круга: '))
            print('Площадь равна', circle.area(radius))
        elif choice == CIRCUMFERENCE_CHOICE:
            radius = float(input('Введите радиус круга: '))
            print('Длина окружности равна', circle.circumference(radius))
        elif choice == AREA_RECTANGLE_CHOICE:
            width = float(input('Введите ширину прямоугольника: '))
            length = float(input("Введите длину прямоугольника: "))
            print('Площадь равна', rectangle.area(width, length))
        elif choice == PERIMETER_RECTANGLE_CHOICE:
            width = float(input('Введите ширину прямоугольника: '))
            length = float(input('Введите длину прямоугольника: '))
            print('Периметр равен', rectangle.perimeter(width, length))
        elif choice == QUIT_CHOICE:
            print('Выходим из программы...')
        else:
            print('Ошибка: недопустимый выбор.')
Ejemplo n.º 7
0
def main():
    # The choice variable controls the loop
    # and holds the user's menu choice.
    choice = 0

    while choice != QUIT_CHOICE:
        # display the menu.
        display_menu()

        # Get the user's choice.
        choice = int(input('Enter your choice: '))

        # Perform the selected action.
        if choice == AREA_CIRCLE_CHOICE:
            radius = float(input("Enter the circle's radius: "))
            print('The area is', circle.area(radius))
        elif choice == CIRCUMFERENCE_CHOICE:
            radius = float(input("Enter the circle's radius: "))
            print('The circumference is', \
                  circle.circumference(radius))
        elif choice == AREA_RECTANGLE_CHOICE:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print('The area is', rectangle.area(width, length))
        elif choice == PERIMETER_RECTANGLE_CHOICE:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print('The perimeter is', \
                  rectangle.perimeter(width, length))
        elif choice == QUIT_CHOICE:
            print('Exiting the program...')
        else:
            print('Error: invalid selection.')
Ejemplo n.º 8
0
def main():
    choice = 0
    while choice != QUIT:
        displayMenu()
        choice = int(input("Enter choice"))
        #menu choice
        if choice == AREA_CIRCLE:
            radius = float(input("Enter the circle's radius "))
            print("Area is ", circle.area(radius))
        elif choice == CIRCUMFRENCE:
            radius = float(input("Enter the circle's radius "))
            print("Circumfrence is ", circle.circumfrence(radius))
        elif choice == AREA_RECTANGLE:
            length = float(input("Enter Length "))
            width = float(input("Enter Width "))
            print("Area is ", rectangle.area(length, width))
        elif choice == PERIMETER_RECTANGLE:
            length = float(input("Enter Length "))
            width = float(input("Enter Width "))
            print("Perimeter is ", rectangle.perimeter(length, width))
        elif choice == QUIT:
            print("Terminated")
        else:
            print("Invalid Selection")
            exit()
Ejemplo n.º 9
0
def main():
    # The choice variable controls the loop
    # and holds the user's menu choice.
    choice = 0

    while choice != QUIT_CHOICE:
        # display the menu.
        display_menu()

        # Get the user's choice.
        choice = int(input('Enter your choice: '))

        # Perform the selected action.
        if choice == AREA_CIRCLE_CHOICE:
            radius = float(input("Enter the circle's radius: "))
            print('The area is', circle.area(radius))
        elif choice == CIRCUMFERENCE_CHOICE:
            radius = float(input("Enter the circle's radius: "))
            print('The circumference is', \
                  circle.circumference(radius))
        elif choice == AREA_RECTANGLE_CHOICE:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print('The area is', rectangle.area(width, length))
        elif choice == PERIMETER_RECTANGLE_CHOICE:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print('The perimeter is', \
                  rectangle.perimeter(width, length))
        elif choice == QUIT_CHOICE:
            print('Exiting the program...')
        else:
            print('Error: invalid selection.')
Ejemplo n.º 10
0
def main():

    # The choice variable controls the loop
    # and holds the user's menu choice.
    choice = 0

    while not (choice == 5):
        # display the menu.
        display_menu()

        # Get the user's choice.
        choice = int(input('Enter your choice: '))

        # Perform the selected action.
        if choice == 1:
            r = float(input("Enter the circle's radius: "))
            print('The area is {:.3f}.'.format(circle.area(r)))
        elif choice == 2:
            radius = float(input("Enter the circle's radius: "))
            print('The circumference is {:.3f}'.format(
                circle.circumference(radius)))
        elif choice == 3:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print('The area is {:.3f}'.format(rectangle.area(width, length)))
        elif choice == 4:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print('The perimeter is {:.3f}'.format(
                rectangle.perimeter(width, length)))
        elif choice == 5:
            print("Exiting the program...")
        else:
            print("Error: invalid selection.")
Ejemplo n.º 11
0
def main():
    # the choice variable control the loops
    # and holds the user's menu choice
    choice=0
    
    while choice!=QUIT_CHOICE:
        # display the menu
        display_menu()
        # get the user's choice.
        choice=int(input("Enter your choice: "))
        # perform the selected action
        if choice==AREA_CIRCLE_CHOICE:
            radius=float(input("Enter the circle's radius: "))
            print("The area is", circle.area(radius))
        elif choice==CIRCUMFERENCE_CHOICE:
            radius=float(input("Enter the circle's radius: "))
            print("The circumference is", circle.circumference)
        elif choice==AREA_RECTANGLE_CHOICE:
            width=float(input("Enter the rectangle's width: "))
            length=float(input("Enter the rectangle's length: "))
            print("The area is", rectangle.area(width,length))
        elif choice==PERIMETER_RECTANGLE_CHOICE:
            width=float(input("Enter the rectangle's width: "))
            length=float(input("Enter the rectangle's length: "))
            print("The perimeter is", rectangle.perimeter(width,length))
        elif choice==QUIT_CHOICE:
            print("Exiting the program...")
        else:
            print("ERROR: Invalid Selection.")
Ejemplo n.º 12
0
def main():
    ''' choice variable controls the loop and the user menu'''
    choice = 0

    while choice != 5:
        # display the menu.
        display_menu()
        # Get the user's choice.
        choice = input ( ' Enter your choice : ' )
        # Perform the selected action.
        if choice == 1:
            radius = input("Enter the circle's radius: " )
            print 'The area is', circle.area(radius)
        elif choice == 2:
            radius = input( "Enter the circle's radius: " )
            print ' The circumference is ' ,  circle.circumference(radius)
        elif choice == 3:
                width = input("Enter the rectangle's width: " )
                length = input("Enter the rectangle's length: " )
                print 'The area is', rectangle.area(width, length)
        elif choice == 4:
                width = input("Enter the rectangle's width: " )
                length = input("Enter the rectangle's length: ")
                print 'The perimeter is ' , \
                        rectangle.perimeter(width, length)
        elif choice == 5:
                print 'Exiting the program . . . '
        else:
                print 'Error: invalid selection.'
Ejemplo n.º 13
0
def main():

    choise = 0

    while choise != QUIT_CHOICE:
        display_menu()

         #получить ввод пользователя
        choise = int(input('Введите вариант: '))

        if choise == AREA_CIRCLE_CHOISE:
            radius = float(input('Введите радиус круга: '))
            print('Площадь окружности равна', circle.area(radius))
        elif choise == CIRCUMFERENCE_CHOISE:
            radius = float(input('Введите радиус круга: '))
            print('Длина окружности равна', circle.circumference(radius))
        elif choise == AREA_RECTANGLE_CHOISE:
            width = float(input("Введите ширину прямоугольника: "))
            length = float(input("Введите длину прямоугольника: "))
            print('Площадь равна', rectangle.area(width,length))
        elif choise == PERIMETER_RECTANGLE_CHOISE:
            width = float(input("Введите ширину прямоугольника: "))
            length = float(input("Введите длину прямоугольника: "))
            print('Площадь равна', rectangle.perimeter(width, length))
        else:
            print('Ошибка: недопустимый выбор')
Ejemplo n.º 14
0
def main():

    choice = 0

    while choice != QUIT_CHOICE:
        display_menu()

        choice = int(input("Enter your choice: "))

        if choice == AREA_OF_CIRCLE_CHOICE:
            radius = float(input("Enter the circle's radius: "))
            print("The area is", circle.area_radius(radius))
        elif choice == CIRCUMFERENCE_CHOICE:
            width = float(input("Enter the rectangle's width: "))
            length = input("Enter the rectangle's length: ")
            print("The circumference is", circle.circumference(width, length))
        elif choice == AREA_RECTANGLE_CHOICE:
            width = float(input("Enter the rectangle's width: "))
            length = input("Enter the rectangle's length: ")
            print("The area is", rectangle.area(width, length))
        elif choice == PERIMETER_RECTANGLE_CHOICE:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print("The perimeter is", rectangle.perimeter(width, length))
        elif choice == QUIT_CHOICE:
            print("Exiting the program...")
        else:
            print("Error: Invalid selection.")
Ejemplo n.º 15
0
def main():
    # the choice variable controls the loop and holds the users menu choice
    choice = 0

    while choice != QUIT_CHOICE:
        # display the menu
        print()
        display_menu()

        # get the users choice
        choice = int(input('Enter your choice: '))
        print()
        # perform the selected action
        if choice == AREA_CIRCLE_CHOICE:
            radius = float(input('Enter the circles radius: '))
            print('The ares is', circle.area(radius))
        elif choice == CIRCUMFERENCE_CHOICE:
            radius = float(input('Enter the circles radius: '))
            print('The circumference is', circle.circumference(radius))
        elif choice == AREA_RECTANGLE_CHOICE:
            width = float(input('Enter the rectangles width: '))
            length = float(input('Enter the rectangles length: '))
            print('The ares is', rectangle.area(width, length))
        elif choice == PERIMETER_CHOICE:
            width = float(input('Enter the rectangles width: '))
            length = float(input('Enter the rectangles length: '))
            print('The perimeter is', rectangle.perimeter(width, length))
        elif choice == QUIT_CHOICE:
            print('Exiting the program')
        else:
            print('Error: invalid selection')
Ejemplo n.º 16
0
def main():
    SELECTION = str(input("Calculate for a (c)ircle or (r)ectangle: "))

    if SELECTION == 'c':
        radius = int(input("Enter the radius of the circle: "))
        print("The area of the circle is: ", circle.area(radius))
        print("The circumference of the circle is: ",\
              circle.circumference(radius))

    if SELECTION == 'r':
        width = int(input("Enter the width of the rectangle: "))
        length = int(input("Enter the length of the rectangle: "))

        print("The area of the rectangle is: ",\
              rectangle.area(width=width,length=length))
        print("The perimeter of rectangle is: ",\
              rectangle.perimeter(width=width,length=length))
Ejemplo n.º 17
0
def main():

    # The choice variable controls the loop
    # and hold the user's menu choice

    choice = 0

    while choice != QUIT_CHOICE:

        # display menu
        display_menu()

        # get user's choice
        choice = int(input("Enter your choice: "))

        # Perform the calculation selected
        if choice == AREA_CIRCLE_CHOICE:
            radius = float(input("Enter the circle's radius: "))
            print("The area is", circle.area(radius))

        elif choice == CIRCUMFERENCE_CHOICE:

            radius = float(input("Enter the circle's radius: "))
            print("The circumference is", circle.circumference(radius))

        elif choice == AREA_RECTANGLE_CHOICE:

            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's lenght: "))
            print("The area is", rectangle.area(width, length))

        elif choice == PERIMETER_REC_CHOICE:

            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's lenght: "))
            print("The parimeter is", rectangle.perimeter(width, length))
        elif choice == QUIT_CHOICE:
            print("Exiting the program.......")

        else:
            print("Error: invalid entry")
Ejemplo n.º 18
0
def main():

    """ Calculates the area and perimeter of rectangle or circle """

    print('This program calculates area and perimeter of a rectangle or circle.')
    choice = int(input('Enter 1 for rectangle or 2 for circle: '))

    if choice == 1:
        length = float(input('Enter length of rectangle: '))
        width = float(input('Enter width of rectangle: '))
        rect_area = rectangle.area(length, width)
        rect_perimeter = rectangle.perimeter(length, width)
        print('Area:', rect_area, 'Perimeter:', rect_perimeter)

    elif choice == 2:
        print('Value of PI in circulations:', circle.PI)
        radius = float(input('Enter radius of circle: '))
        circle_area = circle.area(radius)
        circle_perimeter = circle.circumference(radius)
        print('Area:', circle_area, 'Perimeter:', circle_perimeter)
    else:
        print('Invalid choice')
Ejemplo n.º 19
0
def main():
    # The choice variable controls the loop
    # and holds the user's menu choice.
    choice = 0

    while choice != QUIT_CHOICE:
        # displays the menu.
        display_menu()

        # Get the user's choice.
        choice = int(input('Enter your choice:\t'))

        # Perform the selected action.
        if choice == AREA_CIRCLE_CHOICE:
            radius = get_radius()
            print(f'The area is {circle.area(radius)}')

        elif choice == CIRCUMFERENCE_CHOICE:
            radius = get_radius()
            print(f'The circumfrence is {circle.circumference(radius)}')

        elif choice == AREA_RECTANGLE_CHOICE:
            dimensions = get_rectangle_dimensions()
            # Calculating the result with the dimensions dictionary
            res = rectangle.area(dimensions["width"],dimensions["length"])
            print(f'The area is {res}')

        elif choice == PERIMETER_RECTANGLE_CHOICE:
            dimensions = get_rectangle_dimensions()
            # Calculating the result with the dimensions dictionary
            res = rectangle.perimeter(dimensions["width"],dimensions["length"])
            print(f'The perimeter is {res}')

        elif choice == QUIT_CHOICE:
            print('Exiting the program...')

        else:
            print('Error: invalid selection')
Ejemplo n.º 20
0
def main():
    print(
        'Program geometria pozwala obliczyć pole i obwód koła, prostokąta i trójkata.'
    )

    # W pętli while pobierana jest od użytkownika liczba całkowita
    # odpowiadająca wybranej czynności (od 1 do 5), a następnie
    # w bloku if-elif-else odczytywane są dane i wykonywane obliczenia.
    choice = 0  #inicjalizacja zmiennej choice
    while choice != QUIT_CHOICE:
        display_menu()  #wyświetlenie menu
        #pobranie wartości od użytkownika
        choice = int(input('Wybierz opcję: '))

        #wybór czynności
        if choice == AREA_CIRCLE_CHOICE:  #pole koła
            radius = circle.get_radius()
            print('Pole koła wynosi', circle.area(radius))
        elif choice == CIRCUMFERENCE_CHOICE:  #obwód koła
            radius = circle.get_radius()
            print('Obwód koła wynosi', circle.circumference(radius))
        elif choice == AREA_RECTANGLE_CHOICE:  #pole prosokąta
            (length, width) = rectangle.get_dimensions()
            print('Pole prostokąta wynosi', rectangle.area(length, width))
        elif choice == PERIMETER_RECTANGLE_CHOICE:  #obwód prostokąta
            (length, width) = rectangle.get_dimensions()
            print('Obwód prostokąta wynosi',
                  rectangle.perimeter(length, width))
        elif choice == AREA_TRIANGLE_CHOICE:  #pole trójkąta
            (a, b, c) = triangle.get_lengths()
            print('Pole trójkąta wynosi', triangle.area(a, b, c))
        elif choice == PERIMETER_TRIANGLE_CHOICE:  #obwód trójkąta
            (a, b, c) = triangle.get_lengths()
            print('Obwód trójkąta wynosi', triangle.perimeter(a, b, c))
        elif choice == QUIT_CHOICE:  #koniec programu
            print('Zakończenie działania programu.')
        else:  #wartość spoza listy
            print('Błąd: nieprawidłowa opcja.')
Ejemplo n.º 21
0
def main():
    choice = menu()
    if choice == 1:
        radius = float(input("Enter the radius of the circle:"))
        My_area = circle.area(radius)
        print("The area of a circle is:",format(My_area,'.2f'))
        
    elif choice ==2:
        radius = float(input("Enter the radius of the circle:"))
        My_circum = circle.circum(radius)
        print("The circumference of a circle is:",format(My_circum,'.2f'))
    elif choice ==3:
        length = float(input("Enter the length of the rectangle:"))
        width = float(input("Enter the width of the rectangle:"))
        My_area = rectangle.area(length,width)
        print("The area of the rectangle is:",format(My_area,'.2f'))
    elif choice ==4:
        length = float(input("Enter the length of the rectangle:"))
        width = float(input("Enter the width of the rectangle:"))
        My_peri = rectangle.perimeter(length,width)
        print("The Perimeter of the rectangle is:",format(My_peri,'.2f'))
    else:
        print("Quit")
Ejemplo n.º 22
0
def main():
    choice = 0
    while choice != quit_choice:
        display_menu()
        choice = int(int('Enter your choice: ' ))
        if choice == area_circle_choice:
            radius = float(input"Enter the circle's radius: "))
            print('The area is', circle.area(radius))
        elif choice == circumference_choice:
            radius = float(input("Enter the circle's radius: "))
            print('Ther circumference is', circle.circumference(radius))
        elif choice == area_rectangle_choice:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectabgle's length: "))
            print('The area is', rectangle.area(width,length))
        elif choice == perimeter_rectangle_choice:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print('The perimeter is', rectangle.perimeter(width, length))
        elif choice == quit_choice:
            print('Exitting the program...')
        else :
            print('Error: invalid selection.')
def main():
    width = float(input("Enter the rectangle's width: "))
    length = float(input("Enter the rectangle's length: "))
    print("The area is", rectangle.area(width, length))
    print("The perimeter is", rectangle.perimeter(width, length))
Ejemplo n.º 24
0
def handle_area_of_rectangle(AREA_RECTANGLE_CHOICE):
    width = float(input("Enter the rectangle's width: "))
    length = float(input("Enter the rectangle's length: "))
    return "The area is" + " " + str(rectangle.area(width, length))
#!/usr/bin/env python3
import triangle
import rectangle
import circle

print("Equilateral Triangle, side 4:")
print("a: {0}, p: {1}".format(triangle.area(4,4,4), triangle.perimeter(4,4,4)))
print("Square, side 4:")
print("a: {0}, p: {1}".format(rectangle.area(4,4), rectangle.perimeter(4,4)))
print("Rectange, sides 4, 5:")
print("a: {0}, p: {1}".format(rectangle.area(4,5), rectangle.perimeter(4,5)))
print("Circle, radius 3:")
print("a: {0}, p: {1}".format(circle.area(3), circle.perimeter(3)))
Ejemplo n.º 26
0
def area_of_rect():
    width = float(input("Enter the rectangle's width: "))
    length = input("Enter the rectangle's length: ")
    print(str.format("The area is {:.2f}", rectangle.area(width, length)))
Ejemplo n.º 27
0
#!/usr/bin/env python3
import triangle
import rectangle
import circle

print("Equilateral Triangle, side 4:")
print("a: {0}, p: {1}".format(triangle.area(4, 4, 4),
                              triangle.perimeter(4, 4, 4)))
print("Square, side 4:")
print("a: {0}, p: {1}".format(rectangle.area(4, 4), rectangle.perimeter(4, 4)))
print("Rectange, sides 4, 5:")
print("a: {0}, p: {1}".format(rectangle.area(4, 5), rectangle.perimeter(4, 5)))
print("Circle, radius 3:")
print("a: {0}, p: {1}".format(circle.area(3), circle.perimeter(3)))
 def test_area(self):
     self.assertEqual(area(4, 5), 20, 'message')
Ejemplo n.º 29
0
def main():

    # The choice variable controls the loop
    # and holds the user's menu choice.
    choice = 0

    while not (choice == 5):
        # display the menu.
        display_menu()

        # Get the user's choice.
        choice = int(input('Enter your choice: '))

        # Perform the selected action.
        if choice == 1:
            r = float(input("Enter the circle's radius: "))
            print('The area is {:.3f}.'.format(circle.area(r)))
        elif choice == 2:
            radius = float(input("Enter the circle's radius: "))
            print('The circumference is {:.3f}'.\
                    format(circle.circumference(radius)))
        elif choice == 3:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print("The area is {:.3f}".format(rectangle.area(width, length)))
        elif choice == 4:
            width = float(input("Enter the rectangle's width: "))
            length = float(input("Enter the rectangle's length: "))
            print('The perimeter is {:.3f}'.\
                    format(rectangle.perimeter(width, length)))
        elif choice == 5:
            base = float(input("Enter triangle's base length: "))
            height = float(input("Enter the triangle's height: "))
            print("The area is: {:.3f}".format(triangle.area(height, base)))

        elif choice == 6:
            side_a = float(input("Enter the length of the side a: "))
            side_b = float(input("Enter the length of the side b: "))
            side_c = float(input("Enter the length of the side c: "))
            print("The perimeter of the triangle is: {:.3f}".\
                  format(triangle.perimeter(side_a, side_b, side_c)))

        elif choice == 7:
            radius = float(input("Enter the sphere's radius: "))
            print("The surface area of the sphere is: {:.3f}".\
                  format(sphere.surface(radius)))

        elif choice == 8:
            height = float(input("Enter the sphere's height: "))
            radius = float(input("Enter the sphere's radius: "))
            print("The volume of the sphere is: {:.3f}".\
                  format(sphere.volume(height,radius)))

        elif choice == 9:
            height = float(input("Enter the cylinder's height: "))
            radius = float(input("Enter the cylinder's radius: "))
            print("The surface area of the cylinder is: {:.3f}".\
                  format(cylinder.surface(height, radius)))

        elif choice == 10:
            height = float(input("Enter the cylinder's height: "))
            radius = float(input("Enter the cylinder's radius: "))
            print("The volume of the cylinder is: {:.3f}".\
                  format(cylinder.volume(height, radius)))

        elif choice == 0:
            print("Exiting the program...")
        else:
            print("Error: invalid selection.")
def main():
    width = float(input("Enter the rectangle's width: "))
    length = float(input("Enter the rectangle's length: "))
    print("The area is", rectangle.area(width, length))
    print("The perimeter is", rectangle.perimeter(width, length))
Ejemplo n.º 31
0
def handle_area_of_rectangle():
    width = float(input("Enter the rectangle's width: "))
    length = float(input("Enter the rectangle's length: "))
    return "The area is" + str(rectangle.area(width, length))
Ejemplo n.º 32
0
#def displaymenu():
while (ch == 'y'):
    print("menu")
    print("1.area of the circle")
    print("2.circumference of a circle")
    print("3.area of a rectngle")
    print("4.perimeter of a rectangle")
    print("5.quit")
    choice = int(input("enter your choice:"))
    if (choice == 1):
        radius = int(input("enter the circle's radius:"))
        print("the area is:", circle.area(radius))

    elif (choice == 2):
        radius = int(input("enter the circle's radius:"))
        print("the circumference is", circle.circumference(radius))
    elif (choice == 3):
        width = int(input("enter the rectangle's width:"))
        length = int(input("enter the rectangle's length:"))
        print("the areais", rectangle.area(width, length))
    elif (choice == 4):
        width = int(input("enter the rectangle's width:"))
        length = int(input("enter the rectangle's length:"))
        print("the perimeter is", rectangle.perimeter(width, length))

    elif (choice == 5):
        print("exiting the program..")

    else:
        print('error : invalid selection')