Перейти до змісту

Hello World 🌍

Python 🐍

To create standard developers program "Hello World 🌍!" with Python 🐍 follow this steps:

  1. Create directory (where you want to store Python projects, for example PyExamples), to creat it, use: cd ~ && mkdir PyExamples;
  2. Move to created directory, cd PyExamples/;
  3. Run command python3.11 -m venv .venv - (it will create virtualenv inside .venv directory);
  4. To active virtualenv, use:

    .venv\Scripts\activate.bat
    
    source .venv/bin/activate
    

    Success

    Inside terminal appears (.venv) before your username, this means that your virtualenv activated successfully.

    For example: (.venv) user@User:~/PyExamples$

    Deactivation

    To deactivate virtualenv use:

    deactivate
    

  5. Create hello_world.py inside directory;

  6. Set content of a file to:

    if __name__ == "__main__":
        print("Hello Python!")
    
    print("Hello Python!")
    
  7. Run this code with this command: python -m hello_world. You'll see output inside terminal: Hello World!

Rust 🦀

  1. Create directory (where you want to store Rust projects, for example RsExamples), to creat it, use: cd ~ && mkdir RsExamples;
  2. Move to created directory, cd RsExamples/;
  3. Initialize binary project with cargo new <binary_name>, for example cargo new hello_world
  4. Mode to binary project cd <binary_name>/, for example cd hello_world/
  5. Cargo creates src directory with main.rs file (src/main.rs).
  6. Cargo by default create main.rs with "Hello, world!" program, but you can change it a little:

    1
    2
    3
    fn main() {
        println!("Hello Rust!");
    }
    
  7. Run code with this command cargo run. You'll se output inside terminal: Hello World!