Example #1
0
def main():
    shape = input('What shape do you want? ')
    if shape == 'circle':
        radius = int(input('What is the radius? '))
        print('Circle with radius {} is {}'.format(radius,
                                                   area.circle_area(radius)))
    elif shape == 'square':
        side = int(input('What is the length of a side? '))
        print('Square with sides {} is {}'.format(side,
                                                  area.square_area(side)))
    elif shape == 'rectangle':
        width = int(input('What is the width? '))
        height = int(input('What is the height? '))
        print('Rectangle with width {} and height {} is {}'.format(
            width, height, area.rectangle_area(width=width, height=height)))
    else:
        print('I dunno that shape!')
Example #2
0
 def test_circle_area_with_negative(self):
     with self.assertRaises(ValueError):
         area.circle_area(-5)
Example #3
0
 def test_circle_area_with_zeroes(self):
     self.assertEqual(0, area.circle_area(0))
Example #4
0
 def test_circle_area(self):
     self.assertAlmostEqual(78.5398163, area.circle_area(5))
Example #5
0
#math2.py :to calculate area of a circle only
#calling the sub-module from the module "area"
from area import circle_area
print(circle_area(10))
Example #6
0
#importing the module areain math1.py module
import area
print (area.circle_area(5))
print(area.square_area(10))
print(area.rectangle_area(20,40))
import area
while True:
    print("1. Area of circle")
    print("2. Area of Square")
    print("3. Area of rectangle")
    print("4. Exit")
    choice = int(input("Enter Choice: "))
    if choice == 1:
        r = int(input("Enter radius of circle: "))
        print("Area of Circle= ", area.circle_area(r))
    elif choice == 2:
        s = int(input("Enter side of square= "))
        print("Area of Square= ", area.square_area(s))
    elif choice == 3:
        l = int(input("Enter length ="))
        b = int(input("Enter breadth="))
        print("Area of Rectangle= ", area.rect_area(l, b))
    elif choice == 4:
        break
    else:
        print("Invalid choice")
#!/usr/bin/env python

# Understanding Python function and develop a function - find area
# Importing the module area in math1.py
#:-------------------------------------------- Prog. - 01 --------------------------------------------:
print("Running programme : Prog. - 01")

import area

print("Area of Circel: ", area.circle_area(7))

print("Area of Rectangle: ", area.rectangle_area(3, 4))

print("Area of Square: ", area.square_area(5))
Example #9
0
 def test_circle_area_negative_radius(self):
     with self.assertRaises(ValueError):
         area.circle_area(-3)
Example #10
0
 def test_circle_area_radius_0(self):
     self.assertAlmostEqual(0, area.circle_area(0))
Example #11
0
 def test__circle_area(self):
     self.assertAlmostEqual(12.566370614359172, area.circle_area(2))