Post Reply 
Python comes to the Casio fx-CG 50
12-26-2024, 09:37 PM
Post: #41
RE: Python comes to the Casio fx-CG 50
Thanks for that review.
One consequence of the lack of Unicode is there is no copyright ©️ symbol. The documentation does mention that ASCII must be used, but never makes clear what to expect if the source contains one.

Leaving one wondering whether to expect an alternative symbol printed, a compilation error or a factory reset?

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
12-26-2024, 10:48 PM (This post was last modified: 12-26-2024 10:50 PM by bxparks.)
Post: #42
RE: Python comes to the Casio fx-CG 50
(12-26-2024 09:37 PM)StephenG1CMZ Wrote:  One consequence of the lack of Unicode is there is no copyright ©️ symbol. The documentation does mention that ASCII must be used, but never makes clear what to expect if the source contains one.
Leaving one wondering whether to expect an alternative symbol printed, a compilation error or a factory reset?

Just to make sure that we are on the same page: When I say "unicode support" in MicroPython, I looking at whether the internal implementation of the `str` type in the Python interpreter supports unicode characters. Not whether the Python interpreter supports unicode characters embedded in the source file.

Generally, I never use unicode characters within the source code. I stick to ASCII characters only. Because too many programming tools don't work correctly with unicode (e.g. searching for text inside or outside editors) And I really hate seeing emojis, flags icons, and other such things inside the source code. The darned things are often unrecognizable due to the fonts used by text editors on various computers. So in your example, the copyright symbol would be replaced with (c) in the source file.

But any modern programming language ought to be able to read, manipulate, and write unicode characters. The CG50 MicroPython v1.9.4 cannot do that, because its internal `str` type cannot represent unicode characters.
Find all posts by this user
Quote this message in a reply
12-27-2024, 02:08 PM (This post was last modified: 12-27-2024 02:09 PM by StephenG1CMZ.)
Post: #43
RE: Python comes to the Casio fx-CG 50
By comparison, I have used the Copyright symbol in strings in Numworks without problems. - It displays as a rectangle there, but doesn't cause any issues.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
12-27-2024, 04:04 PM
Post: #44
RE: Python comes to the Casio fx-CG 50
I discovered that there is another MicroPython implementation for the Casio fx-CG50 called PythonExtra. The git repo is here: https://git.planet-casio.com/Lephenixnoi...a/releases. Download the `PythonExtra-pe-0.3.0-beta.zip` file, and copy over the `PythonExtra-pe-0.3.0.g3a` file to the CG50. The forum discussions are here (https://www.planet-casio.com/Fr/forums/t...extra.html), but the vast majority of the discussions are in French.

PythonExtra provides MicroPython v1.23.0 which solves many of the issues that I posted about. In particular, PythonExtra supports unicode strings and f-strings. However, the software is in "beta" phase, and has some deficiencies. Specifically, it currently has an even worse support for entering special ASCII symbols than Casio's MicroPython implementation: there is absolutely no ability to enter them at all through the calculator keypad, in both REPL mode and during `input()`. The maintainer responded that he is now aware of the problem, but will not be able to fix the issue for a while due to time constraints.
Find all posts by this user
Quote this message in a reply
Yesterday, 12:16 AM
Post: #45
RE: Python comes to the Casio fx-CG 50
(12-27-2024 04:04 PM)bxparks Wrote:  I discovered that there is another MicroPython implementation for the Casio fx-CG50 called PythonExtra. The git repo is here: https://git.planet-casio.com/Lephenixnoi...a/releases. Download the `PythonExtra-pe-0.3.0-beta.zip` file, and copy over the `PythonExtra-pe-0.3.0.g3a` file to the CG50. The forum discussions are here (https://www.planet-casio.com/Fr/forums/t...extra.html), but the vast majority of the discussions are in French.

PythonExtra provides MicroPython v1.23.0 which solves many of the issues that I posted about. In particular, PythonExtra supports unicode strings and f-strings. However, the software is in "beta" phase, and has some deficiencies. Specifically, it currently has an even worse support for entering special ASCII symbols than Casio's MicroPython implementation: there is absolutely no ability to enter them at all through the calculator keypad, in both REPL mode and during `input()`. The maintainer responded that he is now aware of the problem, but will not be able to fix the issue for a while due to time constraints.

How do you actually run a program? I have a program called Nqueens.py in the \PYTHON folder and I can't run it directly in shell mode, nor can I import it and run it.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Yesterday, 12:24 AM
Post: #46
RE: Python comes to the Casio fx-CG 50
(Yesterday 12:16 AM)toml_12953 Wrote:  How do you actually run a program? I have a program called Nqueens.py in the \PYTHON folder and I can't run it directly in shell mode, nor can I import it and run it.

- Upload the program to the CG50 using USB Mass Storage. I placed my files at the top level.
- Fire up PythonExtra.
- Press the FILES soft menu (F1) if not already there.
- You should see your file in a list.
- Scroll down to the file using the UP and DOWN arrow keys.
- Hit EXE to run.

My FILES screen looks like this:
   
Find all posts by this user
Quote this message in a reply
Yesterday, 02:25 AM (This post was last modified: Yesterday 02:44 AM by toml_12953.)
Post: #47
RE: Python comes to the Casio fx-CG 50
(Yesterday 12:24 AM)bxparks Wrote:  
(Yesterday 12:16 AM)toml_12953 Wrote:  How do you actually run a program? I have a program called Nqueens.py in the \PYTHON folder and I can't run it directly in shell mode, nor can I import it and run it.

- Upload the program to the CG50 using USB Mass Storage. I placed my files at the top level.
- Fire up PythonExtra.
- Press the FILES soft menu (F1) if not already there.
- You should see your file in a list.
- Scroll down to the file using the UP and DOWN arrow keys.
- Hit EXE to run.

My FILES screen looks like this:

That works if I don't have the program in a def block but if I do (see below) I get back to the >>> prompt and nothing I type seems to be able to run the program.

Code:
def nqueens():
  for i in range(100):
    a=[0] * 9
    r=8
    s=0
    x=0
    y=0
    t=0
    while True:
      x+=1
      a[x]=r
      while True:
        s+=1
        y=x
        while y>1:
          y-=1
          t=a[x]-a[y]
          if t==0 or x-y==abs(t):
            y=0
            a[x]-=1
            while a[x]==0:
              x-=1
              a[x]-=1
        if y==1:
          break
      if x==r:
        break
  print(s)

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Yesterday, 02:39 AM (This post was last modified: Yesterday 02:41 AM by bxparks.)
Post: #48
RE: Python comes to the Casio fx-CG 50
(Yesterday 02:25 AM)toml_12953 Wrote:  That works if I don't have the program in a def block but if I do (see below) I get back to the >>> prompt and nothing I type seems to be able to run the program.

Code:
def nqueens():
....

The easiest solution is probably to add the single line
Code:
nqueens()
at the end of your file and re-upload.

It *might* be possible to type the following in the SHELL screen:
Code:
>>> from nqueens import *
>>> nqueens()
(where `nqueens.py` is the name of your file).

But it is sooo painful to type anything on the calculator keypad, I typed "from" then wanted to shoot myself.
Find all posts by this user
Quote this message in a reply
Yesterday, 03:56 PM
Post: #49
RE: Python comes to the Casio fx-CG 50
On my CG50 if you press SHIFT 4 (Catalogue) you get a full list of Python commands
Press ALPHA F to get "from"
Find all posts by this user
Quote this message in a reply
Yesterday, 04:28 PM
Post: #50
RE: Python comes to the Casio fx-CG 50
(Yesterday 03:56 PM)JeffB Wrote:  On my CG50 if you press SHIFT 4 (Catalogue) you get a full list of Python commands
Press ALPHA F to get "from"

Yup, that works in the `Python` app. It's not implemented in the `PythonExtra` app.
Find all posts by this user
Quote this message in a reply
Yesterday, 06:07 PM
Post: #51
RE: Python comes to the Casio fx-CG 50
(Yesterday 02:39 AM)bxparks Wrote:  
(Yesterday 02:25 AM)toml_12953 Wrote:  That works if I don't have the program in a def block but if I do (see below) I get back to the >>> prompt and nothing I type seems to be able to run the program.

Code:
def nqueens():
....

The easiest solution is probably to add the single line
Code:
nqueens()
at the end of your file and re-upload.

It *might* be possible to type the following in the SHELL screen:
Code:
>>> from nqueens import *
>>> nqueens()
(where `nqueens.py` is the name of your file).

But it is sooo painful to type anything on the calculator keypad, I typed "from" then wanted to shoot myself.

You might have missed it. In my original post I said I can't even import nqueens. All I get is file not found. I checked the spelling and capitalization but no luck.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 




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