jeudi 28 septembre 2017

Functions not being executed

I am super new at coding, taking my first programming class this semester. We have just learned about functions with an assignment to use functions to make a program that calculates the area and perimeter of a rectangle.

When I run the program, nothing happens. I can't figure out why the first function getInt isn't being initialized.

As shown in the code below, the user is not being asked to enter either the width or height. Any and all help is appreciated.

def getInt(wid, hght):
 if wid <1:
    print("Integer value must be between 1 and 60, please re-enter: ")
 if wid >60:
    print("Integer value must be between 1 and 60, please re-enter: ")
 wid=float(input("Enter the width (1 - 60): "))
 if hght<1:
    print("Integer value must be between 1 and 20, please re-enter: ")
 if hght>20:
    print("Integer value must be between 1 and 20, please re-enter: ")
 hght=float(input("Enter the height (1 - 20: "))
 return wid
 return hght

def calcPerimeter(width, height):
 width=getInt.wid
 height=getInt.hght
 perimeter=2*(width+height) 
 return perimeter

def calcArea(width, height):
 width=getInt.wid
 height=getInt.hght
 area=width*height
 return area

def Main():
 getInt
 calcPerimeter
 calcArea
Main()

Aucun commentaire:

Enregistrer un commentaire