Question
how to make my code of python work probely
my q is how to write a code to find the average actual water level, average error by using python
and my program should be flexible where user can select the column no. If you can see in the main program, it asked which column to know the maximum or average, the column number is passed to the function. The function should look which column to do.



FUC Jour plus am UIN dniu IDZYYYY.py in def showmenu(): print(========= === ========== print(Menu:) print(===============





#THIS PROGRAMMING IS ABLE TO FIND THE SLOPE OF TWO POINTS.
def Slope():
x1=eval(input("Please Enter x1 "))
x2=eval(input("Please Enter x2 "))
y1=eval(input("Please Enter y1 "))
y2=eval(input("Please Enter y2 "))
  
if y1 > y2:
swap1 = y2
y2 = y1
y1 = swap1
if x1 > x2:
swap2 = x2
x2 = x1
x1 = swap2
if x1 - x2 == 0 or x2 - x1 == 0:
print("Sorry, The result is not defined")
else:
m = (y2 - y1) / (x2 - x1)
return m

#THIS PROGRAMMING ABLE TO FIND THW AREA OF THE CIRCLE WHEN THE USER DETERMINE THE RADIUS.
def circleArea():
r=eval(input("Please Enter the radius "))
AreaCi = 3.14*(r**2)
return AreaCi

#THIS PROGRAMMINF ABLE TO FIND THE TOTAL AREA AND VOLUME OF ONE OR MORE RECTANGULARS.
def calAreaVolumeRec():
TA=0
TV=0
RN=0
TotalTVTA=0
NOR=eval(input("How many rectangulras you want to calculate"))
TATVWrite = open("Rectangular.txt", "w")
for n in range (NOR):
W=eval(input("Enter the Width"))
L=eval(input("Enter the Lenght"))
H=eval(input("Enter the Height"))
  
AreaRec= W*L
VolumeRec= AreaRec*H
RN=RN+1
TA = TA + AreaRec
TV = TV + VolumeRec
print("The Area and Volume of rec",(RN),"is",AreaRec,"and",VolumeRec)
TATVWrite.write("The values of Rectangular ")
TATVWrite.write(str(RN) + " width " + str(W) + " length " + str(L) + " height " + str(H) + " the area " + str(TA) + " the volume " + str(TV) + " \n")
TATVWrite.close()
return TA,TV
  
def readCalAreaVolumeRec():
ReadFile = open("Rectangular.txt", "r")
for AllData in ReadFile:
print(AllData)
ReadFile.close()

def AverageActualWaterLevel():
openFile = open("wl.txt", "r")
total = 0
N = 0
for lineofCode in openFile:
mydata = lineofCode.split(",")
col1=eval(input("Average Error Between column?"))
col2=eval(input("And column?"))
N = N + 1
total = total + input(col1)+ input(col2)
avg = total / (2*N)
openFile.close()
return avg

def AverageError():
eorrOpenFile = open("wl.txt", "r")
totalError = 0
nError = 0
Substract = 0
for LineCodeError in eorrOpenFile:
errorData = LineCodeError.split(",")
nError = nError + 1
Substract = eval(errorData[3]) - eval(errorData[4])
totalError = totalError + Substract
avgError = totalError / (2*nError)
eorrOpenFile.close()
return nError,totalError,avgError

def HighestError():
HigestEorrOpenFile = open("wl.txt", "r")
Substract = 0
bigNumber = 0
highest = 0
for LineCodeHighestError in HigestEorrOpenFile:
highestErrorData = LineCodeHighestError.split(",")
Substract = eval(highestErrorData[3]) - eval(highestErrorData[4])
if Substract > bigNumber:
bigNumber = Substract
HigestEorrOpenFile.close()
return bigNumber

def RootMeanSquareError():
RootEorrOpenFile = open("wl.txt", "r")
nRootError = 0
RootSubstract = 0
rootTotal = 0
for LineCodeRootError in RootEorrOpenFile:
rootErrorData = LineCodeRootError.split(",")
nRootError = nRootError + 1
RootSubstract = (eval(rootErrorData[3]) - eval(rootErrorData[4]))**2
print("indivual square ",RootSubstract)
rootTotal = rootTotal + RootSubstract
  
avgRootError = (rootTotal / nRootError)**0.5
RootEorrOpenFile.close()
return nRootError,rootTotal,avgRootError

def Nash_SutCliffe():
NashEorrOpenFile1 = open("wl.txt", "r")
NashSubstract = 0
nNashError = 0
SutCliff = 0
sumNashSubstract = 0
sumSutCliffSubstract = 0
finalTotal = 0
for LineCodeNashError1 in NashEorrOpenFile1:
NashErrorData = LineCodeNashError1.split(",")
nNashError = nNashError + 1
NashSubstract = (eval(NashErrorData[3]) - eval(NashErrorData[4]))**2
sumNashSubstract = sumNashSubstract + NashSubstract

NashEorrOpenFile2 = open("wl.txt", "r")
for LineCodeNashError2 in NashEorrOpenFile2:
NashErrorData = LineCodeNashError2.split(",")
SutCliff = ((AverageActualWaterLevel() - eval(NashErrorData[4]))**2)*nNashError
sumSutCliffSubstract = sumSutCliffSubstract + SutCliff
finalTotal = 1 - (sumNashSubstract / sumSutCliffSubstract)
NashEorrOpenFile1.close()
NashEorrOpenFile2.close()
return sumNashSubstract,sumSutCliffSubstract,finalTotal


# --------------------------------------------------------------------Manin Function----------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------------------------------------------

print("Please choose the math problem type you want to slove")
print("If you are looking for Slope then enter ----------------------------------------------------------:1")
print("If you are looking for Circle Area then enter ----------------------------------------------------:2")
print("If you are looking for Area and volume of recentgular/s then enter -------------------------------:3")
print("If you are looking to read the data of Area and volume of recentgula you already saved then enter :4")
print("If you are looking for average actual watrer level then enter ------------------------------------:5")
print("If you are looking for average error then enter --------------------------------------------------:6")
print("If you are looking for highest error then enter --------------------------------------------------:7")
print("If you are looking for root mean square error then enter -----------------------------------------:8")
print("If you are looking for Nash SutCliffe then enter -------------------------------------------------:9\n")
choice = eval(input("Write your choise "))
  
if choice == 1:
print("The slope is",Slope())
  
elif choice == 2:
print("The Area of circle is",circleArea())
  
elif choice == 3:
TA,TV = calAreaVolumeRec()
print("The total of area of rectangulars is ",TA," and the total volume of rectangulars ",TV)
  
elif choice == 4:
readCalAreaVolumeRec()
  
elif choice == 5:
avg = AverageActualWaterLevel()
print("The actual average is ",avg)
  
elif choice == 6:
nError,totalError,avgError = AverageError()
print("The total number of line of data is ",nError)
print("The total error is ",totalError)
print("The average error is ",avgError)
  
elif choice == 7:   
bigNumber = HighestError()
print("The highest number of error is ",bigNumber)
  
elif choice == 8:
nRootError,rootTotal,avgRootError = RootMeanSquareError()
print("The total number of line of data is ",nRootError)
print("The total error is ",rootTotal)
print("The average error is ",avgRootError)
  
elif choice == 9:
sumNashSubstract,sumSutCliffSubstract,finalTotal = Nash_SutCliffe()
print("The sumNashSubstract ",sumNashSubstract)
print("The sumSutCliffSubstract ",sumSutCliffSubstract)
print("The final result is ",finalTotal)

i want to write code to find average between two columns at the same time I have the ablitiy to choose any columns for example col 1 and 2 or col 3 and 4


on your left hand is my data Which i have to find its average. the function that I want it is the abilty to choose two columns and find the average by using the code so at the right my programme as you can see the function name: def average actual water level on blue color is the functino that does not work
Autobeve We Abdullah Fadhel AF - O X Presentation Presentation Side Side File Review View Help Home insert Page Layout Formul


X A File Petresentation de Aulae - We had w Home Insert Page Layout Formulas Data Review Some features might be lost you with
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#All the errors have been rectified:

def Slope():
x1 = eval(input("Please Enter x1 "))
x2 = eval(input("Please Enter x2 "))
y1 = eval(input("Please Enter y1 "))
y2 = eval(input("Please Enter y2 "))
if y1 > y2:
swap1 = y2
y2 = y1
y1 = swap1
if x1 > x2:
swap2 = x2
x2 = x1
x1 = swap2
if x1-x2 == 0 or x2 - x1 == 0:
print("Sorry, The result is not defined")
else:
m = (y2 - y1) / (x2 - x1)
return m

# THIS PROGRAMMING ABLE TO FIND THW AREA OF THE CIRCLE WHEN THE USER DETERMINE THE RADIUS.


def circleArea():
r = eval(input("Please Enter the radius "))
AreaCi = 3.14*(r**2)
return AreaCi

# THIS PROGRAMMINF ABLE TO FIND THE TOTAL AREA AND VOLUME OF ONE OR MORE RECTANGULARS.


def calAreaVolumeRec():
TA = 0
TV = 0
RN = 0
TotalTVTA = 0
NOR = eval(input("How many rectangulras you want to calculate"))
TATVWrite = open("Rectangular.txt", "w")
for n in range(NOR):
W = eval(input("Enter the Width"))
L = eval(input("Enter the Lenght"))
H = eval(input("Enter the Height"))

AreaRec = W*L
VolumeRec = AreaRec*H
RN = RN+1
TA = TA + AreaRec
TV = TV + VolumeRec
print("The Area and Volume of rec", (RN), "is", AreaRec, "and", VolumeRec)
TATVWrite.write("The values of Rectangular ")
TATVWrite.write(str(RN) + " width " + str(W) + " length " + str(L) + " height " +
str(H) + " the area " + str(TA) + " the volume " + str(TV) + " \n")
TATVWrite.close()
return TA, TV


def readCalAreaVolumeRec():
ReadFile = open("Rectangular.txt", "r")
for AllData in ReadFile:
print(AllData)
ReadFile.close()


def AverageActualWaterLevel():
openFile = open("wl.txt", "r")
total = 0
N = 0
for lineofCode in openFile:
mydata = lineofCode.split(",")
col1 = eval(input("Average Error Between column?"))
col2 = eval(input("And column?"))
N = N + 1
total = total + input(col1) + input(col2)
avg = total / (2*N)
openFile.close()
return avg


def AverageError():
eorrOpenFile = open("wl.txt", "r")
totalError = 0
nError = 0
Substract = 0
for LineCodeError in eorrOpenFile:
errorData = LineCodeError.split(",")
nError = nError + 1
Substract = eval(errorData[3]) - eval(errorData[4])
totalError = totalError + Substract
avgError = totalError / (2*nError)
eorrOpenFile.close()
return nError, totalError, avgError


def HighestError():
HigestEorrOpenFile = open("wl.txt", "r")
Substract = 0
bigNumber = 0
highest = 0
for LineCodeHighestError in HigestEorrOpenFile:
highestErrorData = LineCodeHighestError.split(",")
Substract = eval(highestErrorData[3]) - eval(highestErrorData[4])
if Substract > bigNumber:
bigNumber = Substract
HigestEorrOpenFile.close()
return bigNumber


def RootMeanSquareError():
RootEorrOpenFile = open("wl.txt", "r")
nRootError = 0
RootSubstract = 0
rootTotal = 0
for LineCodeRootError in RootEorrOpenFile:
rootErrorData = LineCodeRootError.split(",")
nRootError = nRootError + 1
RootSubstract = (eval(rootErrorData[3]) - eval(rootErrorData[4]))**2
print("indivual square ", RootSubstract)
rootTotal = rootTotal + RootSubstract

avgRootError = (rootTotal / nRootError)**0.5
RootEorrOpenFile.close()
return nRootError, rootTotal, avgRootError


def Nash_SutCliffe():
NashEorrOpenFile1 = open("wl.txt", "r")
NashSubstract = 0
nNashError = 0
SutCliff = 0
sumNashSubstract = 0
sumSutCliffSubstract = 0
finalTotal = 0
for LineCodeNashError1 in NashEorrOpenFile1:
NashErrorData = LineCodeNashError1.split(",")
nNashError = nNashError + 1
NashSubstract = (eval(NashErrorData[3]) - eval(NashErrorData[4]))**2
sumNashSubstract = sumNashSubstract + NashSubstract

NashEorrOpenFile2 = open("wl.txt", "r")
for LineCodeNashError2 in NashEorrOpenFile2:
NashErrorData = LineCodeNashError2.split(",")
SutCliff = ((AverageActualWaterLevel() -
eval(NashErrorData[4]))**2)*nNashError
sumSutCliffSubstract = sumSutCliffSubstract + SutCliff
finalTotal = 1 - (sumNashSubstract / sumSutCliffSubstract)
NashEorrOpenFile1.close()
NashEorrOpenFile2.close()
return sumNashSubstract, sumSutCliffSubstract, finalTotal


# --------------------------------------------------------------------Manin Function----------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------------------------------------------
def main():
print("Please choose the math problem type you want to slove")
print("If you are looking for Slope then enter ----------------------------------------------------------:1")
print("If you are looking for Circle Area then enter ----------------------------------------------------:2")
print("If you are looking for Area and volume of recentgular/s then enter -------------------------------:3")
print("If you are looking to read the data of Area and volume of recentgula you already saved then enter :4")
print("If you are looking for average actual watrer level then enter ------------------------------------:5")
print("If you are looking for average error then enter --------------------------------------------------:6")
print("If you are looking for highest error then enter --------------------------------------------------:7")
print("If you are looking for root mean square error then enter -----------------------------------------:8")
print("If you are looking for Nash SutCliffe then enter -------------------------------------------------:9\n")
choice = eval(input("Write your choise "))

if choice == 1:
print("The slope is", Slope())

elif choice == 2:
print("The Area of circle is", circleArea())

elif choice == 3:
TA, TV = calAreaVolumeRec()
print("The total of area of rectangulars is ", TA,
" and the total volume of rectangulars ", TV)

elif choice == 4:
readCalAreaVolumeRec()

elif choice == 5:
avg = AverageActualWaterLevel()
print("The actual average is ", avg)

elif choice == 6:
nError, totalError, avgError = AverageError()
print("The total number of line of data is ", nError)
print("The total error is ", totalError)
print("The average error is ", avgError)

elif choice == 7:
bigNumber = HighestError()
print("The highest number of error is ", bigNumber)

elif choice == 8:
nRootError, rootTotal, avgRootError = RootMeanSquareError()
print("The total number of line of data is ", nRootError)
print("The total error is ", rootTotal)
print("The average error is ", avgRootError)

elif choice == 9:
sumNashSubstract, sumSutCliffSubstract, finalTotal = Nash_SutCliffe()
print("The sumNashSubstract ", sumNashSubstract)
print("The sumSutCliffSubstract ", sumSutCliffSubstract)
print("The final result is ", finalTotal)

if __name__== "__main__":
main()

# ENd Of Program-------:1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NM snowden@snowden-HP-245-65 - Notebook-PC:-/ codefiles/pHere is the Working output.

Thanks :)

Add a comment
Know the answer?
Add Answer to:
how to make my code of python work probely my q is how to write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Must be in Python 3.6 (please have a screen shot on the code) ex 2.14 :...

    Must be in Python 3.6 (please have a screen shot on the code) ex 2.14 : # Enter three points for a triangle x1, y1, x2, y2, x3, y3 = eval(input("Enter three points for a triangle: ")) # Compute the length of the three sides side1 = ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) ** 0.5 side2 = ((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 -...

  • Hello, In Python Enhance the prior assignment by doing the following 1) Create a class that...

    Hello, In Python Enhance the prior assignment by doing the following 1) Create a class that contain all prior functions MyLib # This function adds two numbers def addition(a, b): return a + b # This function subtracts two numbers def subtraction(a, b): return a - b # This function multiplies two numbers def multiplication(a, b): return a * b # This function divides two numbers # The ZeroDivisionError exception is raised when division or modulo by zero takes place...

  • Directions: Write a code for the following programming exercise in PYTHON!!!!!!! -Design a program that lets...

    Directions: Write a code for the following programming exercise in PYTHON!!!!!!! -Design a program that lets the user enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Here is what i got so far, but for some reason this code only print the Minimum and Maximum. its not printing the Average. def...

  • I am having trouble with my Python code in this dictionary and pickle program. Here is...

    I am having trouble with my Python code in this dictionary and pickle program. Here is my code but it is not running as i am receiving synthax error on the second line. class Student: def__init__(self,id,name,midterm,final): self.id=id self.name=name self.midterm=midterm self.final=final def calculate_grade(self): self.avg=(self.midterm+self.final)/2 if self.avg>=60 and self.avg<=80: self.g='A' elif self.avg>80 and self.avg<=100: self.g='A+' elif self.avg<60 and self.avg>=40: self.g='B' else: self.g='C' def getdata(self): return self.id,self.name.self.midterm,self.final,self.g CIT101 = {} CIT101["123"] = Student("123", "smith, john", 78, 86) CIT101["124"] = Student("124", "tom, alter", 50,...

  • Something is preventing this python code from running properly. Can you please go through it and...

    Something is preventing this python code from running properly. Can you please go through it and improve it so it can work. The specifications are below the code. Thanks list1=[] list2=[] def add_player(): d={} name=input("Enter name of the player:") d["name"]=name position=input ("Enter a position:") if position in Pos: d["position"]=position at_bats=int(input("Enter AB:")) d["at_bats"] = at_bats hits= int(input("Enter H:")) d["hits"] = hits d["AVG"]= hits/at_bats list1.append(d) def display(): if len(list1)==0: print("{:15} {:8} {:8} {:8} {:8}".format("Player", "Pos", "AB", "H", "AVG")) print("ORIGINAL TEAM") for x...

  • python programming: Can you please add comments to describe in detail what the following code does:...

    python programming: Can you please add comments to describe in detail what the following code does: import os,sys,time sl = [] try:    f = open("shopping2.txt","r")    for line in f:        sl.append(line.strip())    f.close() except:    pass def mainScreen():    os.system('cls') # for linux 'clear'    print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")    print(" SHOPPING LIST ")    print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")    print("\n\nYour list contains",len(sl),"items.\n")    print("Please choose from the following options:\n")    print("(a)dd to the list")    print("(d)elete from the list")    print("(v)iew the...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

  • Can you please enter this python program code into an IPO Chart? import random def menu():...

    Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...

  • Please, I need help debuuging my code. Sample output is below MINN = 1 MAXX =...

    Please, I need help debuuging my code. Sample output is below MINN = 1 MAXX = 100 #gets an integer def getValidInt(MINN, MAXX):     message = "Enter an integer between" + str(MINN) + "and" + str(MAXX)+ "(inclusive): "#message to ask the user     num = int(input(message))     while num < MINN or num > MAXX:         print("Invalid choice!")         num = int(input(message))     #return result     return num #counts dupes def twoInARow(numbers):     ans = "No duplicates next to each...

  • Case Study Baseball Team Manager. CMSC 135 Python Chapter 7 Assignment: Use a file to save...

    Case Study Baseball Team Manager. CMSC 135 Python Chapter 7 Assignment: Use a file to save the data Update the program so it reads the player data from a file when the program starts andwrites the player data to a file anytime the data is changed What needs to be updated: Specifications Use a CSV file to store the lineup. Store the functions for writing and reading the file of players in a separate module than the rest of the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT