Add visual code block demarcations to sloum's article.

This commit is contained in:
Solderpunk 2021-08-28 14:18:16 +00:00
parent fae524911c
commit 7c3fab0dc8
1 changed files with 16 additions and 0 deletions

View File

@ -181,9 +181,11 @@ them since passing in paths to files or other input will quickly become useful.
I do not know much about the Windows command line, so from here on I will be
talking about Linux/BSD/OSX. If you enter:
---
cd ~
mkdir programming_practice
cd programming_practice
---
You will move directories to your home directory. The program `cd` takes a file
path as an argument. In this case the `~` is something the shell (the actual
@ -193,7 +195,9 @@ home folder called `programming_practice` and then `cd` into it.
You can always go directly to this folder with:
---
cd ~/programming_practice
---
Then you can run `ls` to see any files or subfolders you may want to work on/in.
@ -255,15 +259,19 @@ type into a file for each of the three languages I recommended above:
Create a file named `hello.py` in the current directory (`nano hello.py`, for
example) and enter the following text:
---
def say_hello():
name = input("What is your name? ")
print("Hello " + name)
say_hello()
---
Then run the following in your terminal/shell:
---
python3 ./hello.py
---
If it doesn't work, make sure you have Python 3 installed (type `python3
--version` at the shell and see if you get a Python version number printed. It
@ -279,6 +287,7 @@ the file is using the `cd` command. Then try running the program again.
Create a file named `hello.lua` and enter the following text:
---
function say_hello()
io.write("What is your name? ")
io.flush()
@ -287,10 +296,13 @@ function say_hello()
end
say_hello()
---
Then run the following in your terminal/shell:
---
lua ./hello.lua
---
If it doesn't work, make sure you have Lua installed (type `lua -v` at the
shell, if you get a version number printed then you are good to go, if not then
@ -310,6 +322,7 @@ Create a directory for the program by running `mkdir go_hello && cd go_hello` at
your shell/terminal. Then create a file named `main.go` and enter the following
text:
---
package main
import (
@ -322,11 +335,14 @@ func main() {
fmt.Scanln(&name)
fmt.Printf("Hello %s", name)
}
---
Then run the following in your terminal/shell:
---
go build
./go_hello
---
You may notice that running the program is a little different here. We call `go
build` first. This compiles the program into an executable file. We then run