-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add more detailed python test code
- Loading branch information
Showing
10 changed files
with
489 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
# Summary | ||
|
||
- [Intro](./intro.md) | ||
- [Intro](intro.md) | ||
- [Python](python/intro.md) | ||
- [Get Started](python/get-started.md) | ||
- [Basics](python/basics.md) | ||
- [Variable and Types](python/variable-and-types.md) | ||
- [Operators](python/operators.md) | ||
- [C]() | ||
- [C++]() | ||
- [Javascript]() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
# Mdbook REPL | ||
|
||
This is a python **realtime** playground which uses pyodide **webassembly** to run python code in the browser. So you can run python code in the browser without any server. | ||
This is a [mdbook](https://rust-lang.github.io/mdBook) playground which uses **webassembly** to execute code in the browser. So you can run code in the browser without any server. | ||
|
||
Below is a simple example, you can run the code and see the output. | ||
This is inspired by mdbook rust playground, but it is not limited to rust. Nowdays, webassembly is very powerful, so I learned it and try to make a playground for multiple languages with mdbook. | ||
|
||
**Python** | ||
Now only **Python** is supported, maybe I will add more languages in the future. | ||
|
||
```python | ||
# This is a default python code | ||
import calendar | ||
# Python | ||
|
||
yy = 2024 # year | ||
mm = 2 # month | ||
|
||
# display the calendar | ||
print(calendar.month(yy, mm)) | ||
print("Hello, World!") | ||
``` | ||
|
||
Tell me if you have any ideas or suggestions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Basics | ||
|
||
## encode | ||
|
||
By default, Python source files are encoded in **UTF-8** and all strings are unicode strings. Of course, you can also specify different encodings for the source code files: | ||
|
||
```plaintext | ||
# -*- coding: cp-1252 -*- | ||
``` | ||
|
||
The above definition allows the use of character encoding from the Windows-1252 character set in the source file, corresponding to Bulgarian, Belarusian, Macedonian, Russian, Serbian. | ||
|
||
## comments | ||
|
||
Python uses the hash character `#` to start a comment. The comment ends at the end of the line. | ||
|
||
```python | ||
# This is a comment | ||
|
||
print("Hello, World!") # This is also a comment | ||
``` | ||
|
||
## multi-line comments | ||
|
||
Python does not have a syntax for multi-line comments, but you can use triple quotes: | ||
|
||
```python | ||
""" | ||
This is a comment | ||
written in | ||
more than just one line | ||
""" | ||
|
||
print("Hello, World!") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Get Started | ||
|
||
## Who should read this tutorial? | ||
|
||
This tutorial is for developers who want to learn the Python programming language from scratch. Of course, this tutorial will also provide some in-depth modules to give you a better understanding of Python applications. | ||
|
||
## The first Python program | ||
|
||
For most programming languages, the first code to get started is "Hello World!", and the following code is to output "Hello World!" in Python: | ||
|
||
```python | ||
# Python | ||
|
||
print("Hello, World!") | ||
``` | ||
|
||
A common Python file extension is .py. | ||
|
||
You can save the above code in a hello.py file and execute the script file with python commands. | ||
|
||
```bash | ||
python hello.py | ||
``` | ||
|
||
You should see the output "Hello, World!" in the terminal or you can run the code in the browser by clicking the **Play** button below. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Python | ||
|
||
Python is a widely used high-level programming language for general-purpose programming, created by Guido van Rossum and first released in 1991. | ||
|
||
Python features a dynamic type system and automatic memory management and supports multiple programming paradigms, including object-oriented, imperative, functional programming, and procedural styles. It has a large and comprehensive standard library. | ||
|
||
You can learn some basics of Python in the following sections. | ||
|
||
```python | ||
# Python | ||
|
||
print("Hello, World!") | ||
``` |
Oops, something went wrong.