Python Forum
Lots of code. Creating modules
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lots of code. Creating modules
#1
This is where I am trying to import the module. Having issues and have tried multiple things.
import geometry # my custom input module



rectWidth = ('Enter the Width of rectangle:')
rectLength = ('Enter the length of rectangle:')
radius = ('Enter the radius of circle:')
triangleHeight = ('Enter the Height of triangle:')
triangleBase = ('Enter the Base of triangle:')
xOne = ('Enter the point of X one:')
xTwo = ('Enter the point of X two:')
yOne = ('Enter the point of Y one:')
yTwo = ('Enter the point of Y two:')

finalRectangle = ('{}'.format(calculaterectangle(rectLength,rectWidth)))

print('{:,.2f}'.format (calculaterectangle(rectLength,rectWidth)))
print('{:,.2f}'.format (calculatecircle(radius)))
print('{:,.2f}'.format (calculatetriangle(height,base)))
print('{:,.2f}'.format (calculatdistance(xOne,xTwo,yOne,yTwo)))



THIS IS THE MODULE ITSELF

import math

# Function: calculaterectangle
# Description: This function will calculate the area of a rectangle
# Input: The user is expected to enter length and width
# Output: A message is displayed explaining what is expected from the user.
# Parameters: prompt - message to display to user
# Returns: user's input of sides
def calculaterectangle(rectLength,rectWidth):
rectangleArea = rectLength * rectWidth
return rectangleArea

# Function: calculatecircle
# Description: This function will calculate the area of a circle
# Input: The user is expected to enter radius
# Output: A message is displayed explaining what is expected from the user.
# Parameters: prompt - message to display to user
# Returns: user's input of radius
def calculatecircle(radius):
circlArea = math.pi * radius ** 2
return circleArea

# Function: calculatetriangle
# Description: This function will calculate the area of a right triangle
# Input: The user is expected to enter base and height of triangle
# Output: A message is displayed explaining what is expected from the user.
# Parameters: prompt - message to display to user
# Returns: user's input of base and height
def calculatetriangle(triangleBase,triangleHeight):
triangleArea = triangleBase*triangleHeight/2
return triangleArea

# Function: calculatedistance
# Description: This function will calculate the distance between two points
# Input: The user is expected to enter two coordinates
# Output: A message is displayed explaining what is expected from the user.
# Parameters: prompt - message to display to user
# Returns: user's input of coordinates
def calculatedistance (xOne,xTwo,yOne,yTwo):
distance = math.sqrt((xTwo-xOne)**2 + (yTwo-yOne)**2)
return distance

It is throwing an error on line 37 that said calculaterectangle is not defined
Reply


Messages In This Thread
Lots of code. Creating modules - by jwhenson1990 - Oct-12-2017, 10:51 PM
RE: Lots of code. Creating modules - by Lux - Oct-12-2017, 11:21 PM
RE: Lots of code. Creating modules - by gruntfutuk - Oct-13-2017, 08:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Code: Creating a basic python game? searching1 5 3,435 Nov-12-2018, 05:18 AM
Last Post: searching1
  Creating code to make up to 4 turtle move simultaneously in a random heading J0k3r 3 5,493 Mar-05-2018, 03:48 PM
Last Post: mpd

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020