Printing in Jupyter notebooks

11 views
Skip to first unread message

peter....@gmail.com

unread,
Apr 29, 2023, 2:44:03 PMApr 29
to
> for n from 0 to 5 do print(n) od;

What do you expect to see?
Well, in Jupyter Notebooks I see: "5".

How to fix this?


Jerry Place

unread,
Apr 29, 2023, 3:59:14 PMApr 29
to
|\^/| Maple 18 (X86 64 LINUX)
._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2014
\ MAPLE / All rights reserved. Maple is a trademark of
<____ ____> Waterloo Maple Inc.
| Type ? for help.
> for n from 0 to 5 do print(n) od;
0

1

2

3

4

5

Rainer Rosenthal

unread,
Apr 29, 2023, 5:28:49 PMApr 29
to
So maybe it's a problem with carriage return / line feed, i.e., the
lines are printed without line feed?

Cheers,
Rainer

peter....@gmail.com

unread,
Apr 30, 2023, 1:31:45 AMApr 30
to
RR> So maybe it's a problem with carriage return / line feed, i.e., the
RR> lines are printed without line feed?

No, wouldn't you expect in this case the output "0 1 2 3 4 5"?
The output is "5", as I wrote.

So I tried two workarounds, but same result with:

> for n from 0 to 5 do lprint(n) od;

and with:

> for n from 0 to 5 do
> printf("%g\n", n);
> end do

---
Greetings to good old Vladimir:
https://www.cybertester.com/images/bug-ass.jpg

Rainer Rosenthal

unread,
Apr 30, 2023, 10:03:30 AMApr 30
to
Am 30.04.2023 um 07:31 schrieb peter....@gmail.com:
> RR> So maybe it's a problem with carriage return / line feed, i.e., the
> RR> lines are printed without line feed?
>
> No, wouldn't you expect in this case the output "0 1 2 3 4 5"?
> The output is "5", as I wrote.
>
As an assembler programmer of old, I used to feed printers and other
output devices character by character. Sometimes ASCII and sometimes
some fancy code.
ASCII code LF = 10 (decimal) is the 'line feed' control character.
The output device is expected to advance to the next line.
ASCII code CR = 13 (decimal) is the 'carriage return' control character.
The output device is expected to put the following characters at the
first position of the same line.

I remember well the nice "wheeling around" when printing p, b, d, q
cyclically on the screen, separated by CR. All characters showed up at
the same place at the beginning of a line on the screen.

What a pity: I tried to replay this old joke, but in vain 🙁
Modern devices don't like a single CR and perform the LF action, too.
(Or, as in your case, they simply interpret CR as blank character.)

I'd love to see the trick again.

See https://en.wikipedia.org/wiki/Carriage_return
and https://en.wikipedia.org/wiki/Newline

Cheers,
Rainer

P.S. That didn't help you much, but I am quite certain that explained
your experience.



jfh

unread,
May 4, 2023, 5:35:56 PMMay 4
to
I often hit this CR/LF problem (but not in Maple) because I use Linux but people who use Microsoft get emails from me that don't look like what I sent. I have never used Jupyter. Was the OP's problem with that or with Maple?
Reply all
Reply to author
Forward
0 new messages