Scientific Computing
python
and nvim
ls
nvim
.py
script that collatescron
commandzsh
git
, however, a critical shell command.
python
or python3
”ls
we see perhaps frustrating differences.
ls
on bash lists only file namesls
on PowerShell lists file names, dates, and morels
on cmd.exe
is an error..py
files you have.ls
command..py
file extension in the command*
*
will “match” any name..py
will “match” and Python file!ls *
? ls *w.py
?rm
Warning
This command is dangerous.
rm
command removes files by name.reply.py
anymore.rm
is sometimes possible, but never easy.mkdir
and the folder name, somv
command.hi.py
?pwd
cd
hi.py
, to a folder, like old
old
cd
ing into it, we use a special destination..
is the name of the folder that contains the folder you are currently in.cd
to change to the containing folder, often called the “parent”rm
, we can also remove folders (or directories).rmdir
old
.py
files, we can use cat
to see what text they contain.touch
echo
command.echo
is also used for shell “Hello, world!”echo
- we can “redirect” what is printed to some file.>
operator
*
Command | Action |
---|---|
ls |
list files in folder |
rm f.txt |
delete file “f.txt” |
mkdir dir |
create a new folder named “dir” |
mv f.txt dir |
move file “f.txt” to folder “dir” |
pwd |
print current folder |
cd dir |
change current folder to “dir” |
cd .. |
go to “parent” folder |
echo hi |
print the text “hi” |
echo hi >f.txt |
write “hi” to file “f.txt” |
cat f.txt |
see the text in f.txt |
cat
it, I am unlikely to know#
pw.py
pw.py
:tax.py
i
and start typing…$
is end-of-linei
modej
down to the 415050 line$
jumps to the end of the line0
is start-of-line0
brings to beginning of line./
let’s us search, so /#
searches for the start of the comment
Practice this a few times!
Tip
I know you can do this with the mouse.
y
to yank and then $
to yank until the end of the line.
$
) and operators (y
)j
to go down to the next line.p
to paste the comment./9
- first character to changer
- replace model
to move right (onto “6”) then dl
to delete the next character./over
- first character to changede
- We introduce the new e
motion for “end of word” and combine with delete.:w
)>
to direct the output to file.nvim
to edit that file into a new Python script that uses the numerical values I found.points.py
, that computes the tax cost at the end of each bracket.tax_policy
list-of-lists!tax.py
Warning
This is an advanced topic.
v
which I use less often.nvim tax.py
5j
to move down 5 linesI
(shift + “i”) to enter “insert block”print()
to directly print things usable as Python.intercepts.py
tax_line.py
# Generate with `intercepts` then modify with visual block mode
taxes = [
[9275, 0.1, 0.0],
[37650, 0.15, -463.75],
[91150, 0.25, -4228.75],
[190150, 0.28, -6963.25],
[413350, 0.33, -16470.75],
[415051, 0.35, -24737.75],
]
def single_tax(income):
# Check all brackets
for tax in taxes:
if income < tax[0]:
return income * tax[1] + tax[2]
# We calculated the top bracket earlier
return income * .396 + -43830.05
Comments