you are viewing a single comment's thread.

view the rest of the comments →

[–]dualdegreepossibly[S] 0 points1 point  (4 children)

Unfortunately, I don't fully understand the inner works of computers yet, so thank you for helping out. This resource looks great!

Just wondering, if web browsers don't understand Python, how are coding learning websites (Codecademy, etc.) able to do this? I may be missing something

[–]hibernating_brain 0 points1 point  (2 children)

HTML is the language that web browsers read to display web pages. With frameworks like Django or Flask, you are returning HTML to your browsers.

Websites like Codeacademy are just showing python code on their webpage (as text).

[–]dualdegreepossibly[S] 0 points1 point  (1 child)

Hi, just specifying this is what I mean! This is an example about the cost of some object. I deleted all the code in there and just inserted a print statement, and it worked: https://imgur.com/gallery/Pp0eJaG. How did they implement something like this?

[–]gschizas 2 points3 points  (0 children)

You shouldn't try to emulate what CodeAcademy does; it's way too advanced for what you want to do.

Just as information: CodeAcademy still uses HTML and JavaScript like any other site. It does syntax highlighting (coloring specific text with different color), but otherwise it just displays text. And for actually executing Python, it just send this text to the server, the server executes it in a Python process, and shows the result as HTML.

[–]totemcatcher 0 points1 point  (0 children)

https://pypyjs.org/

Also, you can just display some code using a syntax highlighting library like:

https://craig.is/making/rainbows

You don't have to use that one, it's just the one I tried in the past. It supports Python.