Post Reply 
Error is not an Error?
06-17-2021, 06:30 PM (This post was last modified: 06-18-2021 03:07 AM by Liamtoh Resu.)
Post: #8
RE: Error is not an Error?
Here is a small python program that calculates the average of three numbers
entered by the user.

Code:

#PYTHON name
# avg3nr02
import math
def pintro():
  print("average three numbers")

def enter_3():
   a,b,c = input("a,b,c? ").split(",")
   print(" " + a + ", " + b + ", " + c)
   return (int(a)+ int(b) +int(c))/3

  
def pout():
   q = enter_3()
   print("the average is ",q)
   
pintro()

pout()

#end 
 
EXPORT avg3nr02()
BEGIN
  PRINT;
  PYTHON(name);
END;


And another version that provides formatted output.

Code:

#PYTHON name
# avg3nr03
import math
def pintro():
  print("average three numbers")

def enter_3():
   a,b,c = input("a,b,c? ").split(",")
   print(" " + a + ", " + b + ", " + c)
   return (float(a)+ float(b) + float(c))/3

  
def pout():
   q = enter_3()
   print("the average is {0:.5f}".format(q))
   
pintro()

pout()

#end 
 
EXPORT avg3nr03()
BEGIN
  PRINT;
  PYTHON(name);
END;

And thanks for the nomenclature for HPPL.

Thanks.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Error is not an Error? - toml_12953 - 06-17-2021, 05:13 AM
RE: Error is not an Error? - Liamtoh Resu - 06-17-2021, 08:48 AM
RE: Error is not an Error? - toml_12953 - 06-17-2021, 02:28 PM
RE: Error is not an Error? - Albert Chan - 06-17-2021, 10:46 AM
RE: Error is not an Error? - Thomas_Sch - 06-17-2021, 11:32 AM
RE: Error is not an Error? - toml_12953 - 06-17-2021, 02:57 PM
RE: Error is not an Error? - Albert Chan - 06-20-2021, 03:25 PM
RE: Error is not an Error? - Liamtoh Resu - 06-17-2021 06:30 PM



User(s) browsing this thread: 1 Guest(s)