Ejemplo n.º 1
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_CYLINDER_CHOICE:
            radius = float(input("Enter the circle's width: "))
            height = float(input('Enter the height of cylinder'))
            area = 2 * circle.area(radius) + circle.circumference(
                radius) * height
            print('The total area of cylinder is', area)
        elif choice == QUIT_CHOICE:
            print('Exiting the program. . .')
        else:
            print('Error: invalid selection.')
Ejemplo n.º 2
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.º 3
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')
def main():
    radius = random.randrange(1, 10)
    #radius = float(input('Enter the radius of the cylinder'))
    height = float(input('Enter the height of cylinder'))

    TSA = 2 * circle.area(radius) + height * circle.circumference(radius)
    print(TSA)
Ejemplo n.º 5
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.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
0
def surface(height, radius):
    #surface area  = (2 * pi * radius * height) + (2 * pi * r^2)
    #              = (base circumference * height) + (2 * base area)
    #              = area of sides + area of two ends
    ends_area =  2 * circle.area(radius)
    sides_area = circle.circumference(radius) * height
    return ends_area + sides_area
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('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.º 15
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.º 16
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.º 17
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.º 18
0
def main():
    radius = read_radius()
    while radius != 0:
        area = circle.area(radius)
        circumference = circle.circumference(radius)
        print('Area is ' + str(area))
        print('Circumference is ' + str(circumference))
        radius = read_radius()
Ejemplo n.º 19
0
def main():
    radius1 = 3
    area1 = circle.area(radius1)
    diameter1 = circle.diameter(radius1)

    print(f'area is: {area1: .2f}')
    print(f'diameter in: {diameter1: .2f}')

    # demonstrates the use of a cache for imported modules.
    # in main we import circle which in turn imports constants.
    # in main we also import and use constants.
    # however when main executes. 'in constants module' prints
    # once not twice. This is because python caches the variables
    # created in the first import of constants then subsequent uses
    # reference those cached values.
    print(f'pi is {constants.PI}')
Ejemplo n.º 20
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.º 21
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.º 22
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.º 23
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.º 24
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.º 25
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.')
Ejemplo n.º 26
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))
        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.º 27
0
 def test_area(self):
     # test when radius is >= 0
     self.assertAlmostEqual(area(1), pi)
     self.assertAlmostEqual(area(0), 0.0)
     self.assertAlmostEqual(area(2.1), pi * 2.1**2)
Ejemplo n.º 28
0
import circle
print circle.pi
print circle.area(3)
print circle.circumference(3)
print circle.sphereSurface(3) 
Ejemplo n.º 29
0
import circle

#print pi # this does not work
print circle.pi
pi=0
circle.pi=100
print circle.area(2)

#pi=100
#print pi 
#from circle import *
#
#print pi # this does not work
#
#pi=100 # cannot overwrite!!!
#print area(2)
Ejemplo n.º 30
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)))
Ejemplo n.º 31
0
def handle_area_of_circle():
    radius = float(input("Enter the circle's radius: "))
    print(str.format("The area is {:.2f}", circle.area(radius)))
 def test_if_area_is_positive(self):
     # Test when area is >= 0
     self.assertAlmostEqual(area(1), pi)
     self.assertAlmostEqual(area(0), 0.0)
     self.assertAlmostEqual(area(2.2), pi * 2.2**2)
Ejemplo n.º 33
0
import circle

pi = 3
print(pi)
print(circle.pi)
print(circle.area(3))
print(circle.circumference(3))
Ejemplo n.º 34
0
import circle as c # Import circle.py file, also includes math
import sys # For arguments

rad = float(input("Radius of a circle: "))

print("Area: ", c.area(rad))

print("Circumference: ", c.circumference(rad))
Ejemplo n.º 35
0
def main():
    radius = 4
    print c.area(radius)
    f("Fall", "Winter", Sprint="Verizon", Gym=12, x=8957, bob=True)
    print fib(10)
    print reverseString("palindrome")
#!/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.º 37
0
import circle

rad = float(input("Radius of a circle: "))

print("Area: ", circle.area(rad))

print("Circumference: ", circle.circumference(rad))

Ejemplo n.º 38
0
    else:
        return fib(x-1) + fib(x-2)

def testFib(n):
    for i in range(n+1):
        global numFibCalls
        numFibCalls = 0
        print('fib of', i, '=', fib(i))
        print('fib called', numFibCalls, 'times.')

#Page 52, See circle.py

#Page 52
import circle
print( circle.pi)
print( circle.area(3))
print( circle.circumference(3))
print( circle.sphereSurface(3))

from circle import *
print(pi)
print(circle.pi)

#Page 53
nameHandle = open('kids', 'w')
for i in range(2):
    name = input('Enter name: ')
    nameHandle.write(name + '\n')
nameHandle.close()

#Page 54