Python Coding - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: Not HP Calculators (/forum-7.html) +--- Forum: Not remotely HP Calculators (/forum-9.html) +--- Thread: Python Coding (/thread-18374.html) |
Python Coding - Gamo - 05-16-2022 12:06 PM Been a long time, anyway while learning on how to code using the Python Programming Language and my first program is of cause the good old "Profit on Pricing" calculations. This program I use the same algorithm on my several HP programmable calculator found elsewhere here. Here I'll share my code and this might be useful to some who also learn coding. This link user can run this program and try out. Enjoy !! Link: https://trinket.io/python/656c020f51?runOption=run Gamo 5/2022 RE: Python Coding - Thomas Klemm - 05-17-2022 12:36 AM You can use this Python to RPN - source code converter to translate your Python code for the HP-42S. However, I had to adjust it a little bit to make it work: Code: LBL("Profit on Pricing") Some of the generated code can be simplified a bit. For instance the following snippet: Code: if MAR == 0: # if true compute Margin … is translated to: Code: RCL "MAR" // MAR But we can use instead: Code: RCL "MAR" // MAR However the generated code to print the results doesn't appear to work. Still I hope that you have fun with Python and your programs! |