python program with formatted input and output - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: python program with formatted input and output (/thread-17126.html) python program with formatted input and output - Liamtoh Resu - 06-18-2021 03:37 AM Here is a simple prime python program that features formatted input and output statements. It just averages three values entered by a user. 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;``` I included this code in another thread but I thought it might get buried for another user looking for the formated input and output. Thanks. RE: python program with formatted input and output - toml_12953 - 06-18-2021 02:08 PM (06-18-2021 03:37 AM)Liamtoh Resu Wrote:  Here is a simple prime python program that features formatted input and output statements. It just averages three values entered by a user. Code: ```    print("the average is {0:.5f}".format(q))``` I included this code in another thread but I thought it might get buried for another user looking for the formated input and output. Thanks. The above won't work on my Prime. I need to use the older format statement something like this: Code: `print("the average is %.5f" %(q))` RE: python program with formatted input and output - Liamtoh Resu - 06-18-2021 04:36 PM Hmm, this is puzzling for me. I just double checked the prime python code. The program runs fine there. I will try your format statement. I have the 20210505 firmware on the prime g2. It has CAS version 1.5.0 with the operating system version being 2.060.650. .... And I just made a new version with your print statement. Both versions worked on the prime G2. Thanks.