简体   繁体   English

如何在 HP Prime 图形计算器上运行 Python?

[英]How can I run Python on my HP Prime graphing calculator?

According to this firmware post , the HP Prime graphing calculator supports Python.根据此固件帖子,HP Prime 图形计算器支持 Python。 However, I cannot find any guide as to how to run python files in the calculator (even within HP's own 700 page long user manual).但是,我找不到任何关于如何在计算器中运行 python 文件的指南(即使在惠普自己的 700 页长的用户手册中)。 Does anyone know how to execute these files?有谁知道如何执行这些文件?

  • For reference, I have HP Prime's connectivity kit (CK) installed, so I am somewhat able to transfer python code (by copy-pasting into CK's "Programs" section).作为参考,我安装了 HP Prime 的连接工具包 (CK),因此我能够传输 python 代码(通过复制粘贴到 CK 的“程序”部分)。 However, I think it's reading it as Prime Programming Language instead, as it does not run.但是,我认为它是作为 Prime 编程语言阅读的,因为它不运行。

Edit: HP Prime has rebooted and now there is a Python app, allowing me to run some files.编辑:HP Prime 已重新启动,现在有一个 Python 应用程序,允许我运行一些文件。 Unfortunately, I cannot access any Python libraries .不幸的是,我无法访问任何 Python 库 That is, I can only run files that do not have "import _____" in them.也就是说,我只能运行其中没有“import _____”的文件。 This seems like a problem;这似乎是个问题; anyone know how to resolve?有谁知道如何解决?

Also a further problem is that the files are not actually saved in my calculator, as far as I can tell.还有一个问题是,据我所知,这些文件实际上并没有保存在我的计算器中。

i have the firmware update installed on my daughter's HP Prime and it works.我在我女儿的 HP Prime 上安装了固件更新,并且可以正常工作。 After installing the firmware i was able to create with the connectivity kit a Python application first which then is transfered in 'Program' under the name Python (app) with a pretty Python icon aside.安装固件后,我能够使用连接工具包首先创建一个 Python 应用程序,然后以 Python (app) 的名称在“程序”中传输,旁边有一个漂亮的 Python 图标。 This python app can be edited and i can test it,example:这个 python 应用程序可以编辑,我可以测试它,例如:

def it():
  x=exp(3)
  return x

if i run it in the CAS:如果我在 CAS 中运行它:

it()它()

e^3 e^3

you will notice there is no need for importing exp from math and that the result is computed symbolically !您会注意到不需要从数学中导入 exp 并且结果是符号计算的! but it works.但它有效。

For python coding i prefer to use another method: after the firmware update there is a new HP application when pressing 'Apps' you have now Python,clik on it and it will create a new main.py file you can edit.对于 python 编码,我更喜欢使用另一种方法:固件更新后,按下“应用程序”时会出现一个新的 HP 应用程序,您现在有了 Python,单击它,它将创建一个新的 main.py 文件,您可以对其进行编辑。 Editing can be done by clicking on 'Symb' key,example to test math import:可以通过单击“符号”键进行编辑,例如测试数学导入:

from math import *

x=exp(3)
print(x)

now click on 'Num' key to go to the Python console, the HP will run automatically the main.py code:现在点击“Num”键进入 Python 控制台,HP 将自动运行 main.py 代码:

import main进口主要

20.0855369231877 20.0855369231877

you can type other command like : from main.py import function2import您可以键入其他命令,例如: from main.py import function2import

The Python app have a lot of features in the sub menus: Python 应用程序在子菜单中有很多功能:

Templt contains a lot of Python syntax Templt 包含大量 Python 语法

Cmds contains a lot of import and functions to use. Cmds 包含很多导入和使用的功能。

Enjoy!享受! the only caveat i dislike is the lack of syntax highlightning in color like on other calculators.我不喜欢的唯一警告是缺少像其他计算器一样的颜色突出显示语法。 Perheaps in another update!可能在另一个更新中!

I couldn't really find a good source to read about Python support in this particular brand, but in general, graphing calculators have much more limited memory than personal computers, so they do not choose CPython or any of the heftier implementations of the Python language.我真的找不到一个很好的资源来阅读这个特定品牌的 Python 支持,但总的来说,图形计算器的内存比个人计算机有限得多,所以他们不选择 CPython 或任何更重要的 Python 语言实现. They will instead use lightweight implementations like MicroPython or CircuitPython (not these ones exactly but maybe a derivation).他们将改为使用 MicroPython 或 CircuitPython 之类的轻量级实现(不完全是这些,但可能是派生的)。

These implementations don't have the full standard library of CPython and can have different modules particular to their intended contexts.这些实现没有完整的 CPython 标准库,并且可以具有特定于其预期上下文的不同模块。 There probably ARE some modules you can use, but without proper documentation it's hard to say which.可能有一些模块可以使用,但是如果没有适当的文档,很难说是哪个。 It may go without saying but you are certainly restricted from downloading arbitrary Python libraries.这可能不言而喻,但您肯定无法下载任意 Python 库。

i struggled a lot with python on the hp prime as well.我也在 hp prime 上与 python 斗争了很多。 I would suggest to look the libs up inside the calculator.我建议在计算器内查找库。 (Apps->Python->Cmds->7.math->from math import *) You can see all the commands like pi, sqrt, ... as well) I dont know if i got it right but i can give you another example how i did the coding. (Apps->Python->Cmds->7.math->from math import *)你可以看到所有的命令,比如 pi,sqrt,...)我不知道我是否做对了,但我可以给你另一个例子我是如何编码的。 [HP CK1][1] [HP CK1][1]

[HP CK2][2] Main [HP CK2][2]主要

Export ppl()
Begin
  Your_Function();
End;

Your_Function Your_Function

#PYTHON EXPORT Your_Function()

from math import *

U_z=float(input("U_z: "))
print(U_z)
U_rz=float(input("U_rz: "))
print(U_rz)
degr=float(input("degr: "))
print(degr)
freq=float(input("freq: "))
print(freq)

print(pi*sqrt(freq))

#end

To execute it go to Apps->Press "Shift"+"Program" to open the Program Catalog.要执行它,请转到应用程序->按“Shift”+“程序”打开程序目录。 Navigate to your script name.导航到您的脚本名称。 Press "Run" on the buttom right on your screen and hope for no error.按屏幕右侧按钮上的“运行”,希望没有错误。 ;) [1]: https://i.stack.imgur.com/cgG0w.png [2]: https://i.stack.imgur.com/H25Sd.png ;) [1]: https://i.stack.imgur.com/cgG0w.png [2]: https://i.stack.imgur.com/H25Sd.png

Bonjour,你好,

Excuse me, my english is very litle, when wright in french.对不起,当赖特在法语中时,我的英语很少。

Je pars du principe que ce n'est pas du vrai pythons. Je pars du principe que ce n'est pas du vrai pythons。

En effet, en ayant fait quelque programme en cherchant pas à pas, j'en viens à penser que l'application est un mapping des commandes natives (hppl). En effet, en ayant fait quelque program en cherchant pas à pas, j'en viens à penser que l'application est un mapping des commandes natives (hppl)。

En effet, je relève des incohérence et des manques dans le python et le fait que l'on est obligé de passer par la commande 'eval' dans un certain nombre de cas. En effet, je relève des incohérence et des manques dans le python et le fait que l'on est obligé de passer par la commande 'eval' dans un certain nombre de cas。 , De plus, l'application micro python, n'intègre pas la gestion complète des couleurs de l'écran en rgb[8,8,8] et que le get_pixel python bug et ne gere que la la partie écran sens les menus (constat fait à la suite de divers tests). , De plus, l'application micro python, n'intègre pas la gestion complète des couleurs de l'écran en rgb[8,8,8] et que le get_pixel python constat fait à la suite de divers 测试)。 Constat en python, l'écran n'est pas maîtrisé et la, gestion des couleurs est en dessous des capacité de l,a machine: l'application micro python ne gère pas le RGB[8,8,8] (c'est en dessous: exemple le jaune FFFF00 est vers pâle). Constat en python, l'écran n'est pas maîtrisé et la, gestion des couleurs est en dessous des capacité de l,a machine: l'application micro python ne gère pas le RGB[8,8,8] (c en dessous:例如 le jaune FFFF00 est vers pâle)。

Tout ça pour dire que en considération des constatations graphiques faite, pour le reste, cela semble être la même chose. Tout ça pour dire que en consideration des constatations graphiques faite, pour le reste, cela semble être la meme 选择。

C'est tout. C'est吹捧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用带有海龟图形的Python制作线性图形计算器? - How do I make a linear graphing calculator in Python with turtle graphics? 如何使用Tkinter在Python中完成我的计算器? - How can I complete my calculator in Python with Tkinter? 如何在 Python3 中简化我的计算器代码? - How can I simplify my calculator code in Python3? 如何在我的第一个 python 计算器中修复这个 while 循环? - How can I fix this while loop in my first python calculator? Python素数计算器 - Python prime number calculator Python-Prime Finder /计算器错误 - Python - Prime finder/calculator error 如何在我的 python 计算器上制作平方根按钮(我是初学者) - How can i make a square root button on my python calculator (i am a beginner) 如何在不要求用户输入任何内容的情况下重复计算器代码? - Python 中的连续计算 - How can I make my calculator code repeat without asking the user to input anything? - continuous calculation in Python 我可以在自己的代码中使用 Python shell 的计算器吗? - Can I use the calculator of the Python shell in my own code? 如何使用Python 3使用if语句在计算器中进行减法和除法运算? - How can I get subtraction and division in my calculator using Python 3 to work using an if statement?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM