id: loyA61WU1WQrcxuH
createdBy: 15sg55Z9lOgM
dateCreated: 1713192447956
name: 'Lab-Linux: Python-Programming'
meta:
logo: https://raw.githubusercontent.com/edrys-labs/lab-linux/main/media/python.jpg
description: >-
This Python programming course is designed to introduce young learners to the exciting world of coding.
Students will start by writing a simple program that prints a message to the screen.
They'll then enhance their program to interact with users by taking input and responding to it.
Along the way, they'll learn how to identify and fix a common coding error, and finally, they'll explore the Python REPL (Read-Eval-Print Loop), a tool that allows them to experiment with Python code in real-time.
selfAssign: true
defaultNumberOfRooms: 0
members:
teacher: []
student: []
modules:
- url: https://edrys-labs.github.io/module-markdown-it/index.html
config:
content: >-
# Welcome to Lab-Linux: Python-Programming
Python is like a magic wand for computers—it lets you tell them exactly what to do in a way that's easy to understand and fun to learn!
Python is one of the most popular programming languages in the world because it's really simple for beginners but also powerful enough for the pros.
Imagine you could write your own instructions for a magic spell that makes the computer do cool tricks like drawing pictures or solving math problems—that's kind of what programming with Python is like!
### Why Python is Awesome for Young Programmers:
1. **Easy to Read and Write**:
Python looks a lot like the English language, with a focus on readability.
This makes it easier for you to learn how to program and remember what your code is supposed to do.
2. **Versatile**:
Python can be used for so many different things—from creating web applications and games to handling big data and performing scientific computations.
Whatever you're interested in, Python can help you build it.
3. **Great Starting Point**:
Many schools and universities teach Python as a first programming language because it's a great way to introduce students to how coding works.
Plus, there's a huge community of Python programmers who create helpful tools and tutorials, so it's easy to find answers and get help when you need it.
4. **Fun**:
With Python, you can start creating your own projects quickly.
It's fun to see results without having to write a lot of code, and that makes learning really enjoyable.
### Introduction to Python and Programming
Python was created by Guido van Rossum and released in 1991.
The goal was to make a language that was both easy to read and write.
That's why Python is often praised for its simplicity and elegance.
In programming, you write down instructions for the computer to follow.
These instructions are called "code," and when the computer follows your code, it can do nearly anything you can think of.
Programming is a lot like crafting—you start with an idea, use tools (like Python) to shape that idea, and create something completely new.
By learning Python, you're not just learning a language; you're learning how to think like a programmer, which means breaking down problems into smaller pieces and solving them logically.
In this tutorial, you'll explore the basics of Python programming, and by the end, you'll have the skills to create your own simple programs.
Python is your first step into a world where you can bring your creative ideas to life in the form of fun games, helpful applications, and so much more! Ready to start this adventure? Let's dive in!
__Visit a station by clicking onto it and then explore the terminal ;-)__
studentConfig:
content: ''
teacherConfig:
content: >-
## Welcome for Teachers
> This can be used as a base laboratory to create further and more elaborate labs with [edrys-Lite](https://edrys-labs.github.io).
> You are currently in the Lobby.
> If there is a station available you can switch to it and try out the terminal.
> Otherwise, if you are in teacher-mode you can share a lab by clicking onto `setting` >> `station` and then by clicking the presented link,
> which is the same as the current link, but only with the word `station` instead of `classroom`.
stationConfig:
content: ''
showInCustom: lobby
width: full
height: huge
- url: https://edrys-labs.github.io/module-editor/index.html
config:
editorText: Starting text in editor...
runCommand: execute
language: cpp
theme: light
studentConfig: ''
teacherConfig: ''
stationConfig: ''
showInCustom: station
width: full
height: medium
- url: https://edrys-labs.github.io/module-markdown-it/index.html
config:
content: >-
# Welcome to the Station
#### Tutorial Part 1: Your First Python Program
Let's kick off with a very basic Python program that says hello to the world.
1. **Type or Copy the Following Python Code into the Editor**:
```python
print("Hello, World!")
```
3. **Run the Program**:
Hit the run button in your online editor.
You should see the output `Hello, World!` displayed on the screen.
Congratulations, you've just written and executed your first Python program!
#### Tutorial Part 2: Enhance Your Program
Now, let's make your program interactive by asking for the user's name and greeting them personally.
1. **Modify Your Program**:
```python
name = input("Enter your name: ")
print("Hello, " + name + "!")
```
2. **Run the Program**:
When you execute this updated program, it will prompt you to enter your name.
Type your name into the input box and press enter.
You should then see a message that greets you by name.
#### Tutorial Part 3: Introduce an Error
To help you learn how to solve problems, let's introduce a mistake in the code.
1. **Introduce an Error**: Modify the greeting line to use an undefined variable:
```python
name = input("Enter your name: ")
print("Hello, " + person + "!")
```
2. **Run the Program and Observe the Error**:
The interpreter will display an error message like "`NameError: name 'person' is not defined`".
This error occurs because `person` was not defined before it was used.
3. **Fix the Error**:
Change `person` back to `name` to correct the error and run your program again.
#### Tutorial Part 4: Introduction to the REPL
Finally, let's explore the Python REPL, which lets you interact with Python directly to test small pieces of code quickly.
1. **Access the REPL**: Type in the command prompt `python` or `python3` and press Enter.
2. **Use the REPL**:
In the REPL, you can type Python code directly and see the results immediately.
Try it out:
```python
>>> print("Hello from the REPL!")
Hello from the REPL!
```
3. **Experiment**: You can use the REPL to experiment with Python commands, test expressions, or troubleshoot small code snippets.
4. **Exit the REPL**: To exit the REPL, type `exit()` or press `Ctrl+D`.
studentConfig:
content: ''
teacherConfig:
content: ''
stationConfig:
content: >-
## Instructions for Station-Sharing
You are currently responsible for sharing a station of this lab.
You have multiple options to share a or your terminal.
Therefor we use the pyxtermjs - terminal server from:
https://github.com/edrys-labs/module-pyxtermjs
### Using Docker
If you haven't done it so far, install
[docker](https://docs.docker.com/engine/install/).
Or, follow one of the instruction-videos for your system:
Install Docker on LinuxInstall Docker on WindowsInstall Docker on MacOS
Then the only thing that is required is to run the following command:
```bash
docker run -it -p 5000:5000 crosslab/edrys_pyxtermjs_development:latest
```
This will download the pyxtermjs terminal-server from docker-hub and run
it in a secure environment.
It contains support for:
- `clojure`
- `g++`
- `gcc`
- `golang`
- `haskell`
- `java`
- `lua`
- `mono`
- `nodejs`
- `python 3`
- `r`
- `rustc`
### Using Python
You can also share your terminal directly via Python, visit the following
project
https://github.com/edrys-labs/module-pyxtermjs
... the easiest way is to perform the following steps:
``` bash
# 1. clone the repository or download the folder manually
git clone https://github.com/edrys-labs/module-pyxtermjs
# 2. install all required sources
pip3 install -r requirements.txt
# 3. run the terminal-server
python3 -m pyxtermjs --cors True --command bash --port 5000
```
showInCustom: station
width: half
height: huge
- url: https://edrys-labs.github.io/module-pyxtermjs/index.html
config: ''
studentConfig: ''
teacherConfig: ''
stationConfig:
server: http://localhost:5000/pty
execute: execute
script: |-
echo $CODE | base64 --decode > main.py
python3 main.py
enable:
teacher: true
student: true
showInCustom: station
width: full
height: medium