Computer Literacy
Total Page:16
File Type:pdf, Size:1020Kb
Alexey Shipunov COMPUTER LITERACY Make computer do the dirty work January 27, 2020 Make the computer do the dirty work. Tim O’Reilly Shipunov, Alexey. Computer Literacy. Make the computer do the dirty work. January 27, 2020 version (draft). 147 pp. Title page image: Tux, Linux mascot. Some other heading illustrations were taken (with deep gratitude) from XKCD, https://xkcd.com. CTAN lion drawing is by Du- ane Bibby; thanks to www.ctan.org. This work is dedicated to public domain. Contents Data 9 Chapter 1. Text ................................... 11 Text software ................................... 12 Chapter 2. Operating systems .......................... 13 Chapter 3. Files and file systems ......................... 15 File name extensions ............................... 16 Organize your files ................................ 17 File operations .................................. 17 File metadata ................................... 18 File managers. OFM ............................... 18 Privacy and cleaning ............................... 19 Chapter 4. Internet ................................. 20 Internet protocols ................................ 20 Chapter 5. Licenses ................................. 22 Chapter 6. Intro to spreadsheets ......................... 24 Format ...................................... 24 Formulas ..................................... 25 Drag and fill ................................. 25 Protect ................................... 26 Ranges .................................... 26 Conditions ................................. 26 Tab delimited ................................... 27 Chapter 7. Markup and ebooks .......................... 28 Plain text ..................................... 28 HTML ....................................... 28 My first Web page ............................. 28 How to work with HTML .......................... 29 Second HTML document .......................... 29 CONTENTS 5 Step three. Fancy HTML .......................... 30 Step four. PNG and JPEG .......................... 31 Step five. SVG ................................ 34 Step six. CSS ................................ 36 Step seven. JavaScript. ........................... 36 Symbol ebooks .................................. 37 PDF ..................................... 37 EPUB .................................... 38 Scanned ebooks ................................. 38 DjVu ..................................... 38 Chapter 8. TEX ................................... 41 LATEX ........................................ 41 My firstAT L EX document .......................... 41 Second LATEX document .......................... 42 LATEX ebooks ................................. 44 Commands 45 Chapter 9. CLI is to command .......................... 46 Chapter 10. Terminals and where to find them . 47 Chapter 11. UNIX Power Tools .......................... 50 Navigate ...................................... 50 Files ........................................ 51 Find ........................................ 52 Directories .................................... 52 Help ........................................ 55 Pipes and other connections .......................... 55 Text ........................................ 56 Regexp ...................................... 58 Connect ...................................... 60 Script ....................................... 60 UNIX Power Tools cheatsheet .......................... 62 Chapter 12. Intro to Python ........................... 65 First things first ................................. 65 Installing Python ................................. 65 2 or 3? .................................... 66 Interactive Mode ................................. 66 6 CONTENTS Python in Web Browser ............................. 67 Chapter 13. Hello, World! ............................. 68 Creating and Running your First Program ................... 68 Printing ...................................... 69 Quotes ....................................... 70 Expressions .................................... 71 Talking to humans (and other intelligent beings) ............... 73 Examples ..................................... 73 Exercises ..................................... 74 Chapter 14. Who Goes There? .......................... 75 Input and Variables ............................... 75 Assignment .................................... 77 Examples ..................................... 79 Exercises ..................................... 80 Chapter 15. Count to 10 .............................. 81 While loops .................................... 81 Examples ..................................... 83 Exercises ..................................... 84 Chapter 16. Decisions ............................... 85 If statement .................................... 85 Examples ..................................... 87 Exercises ..................................... 90 Chapter 17. Debugging .............................. 91 What is debugging? ............................... 91 What should the program do? .......................... 91 What does the program do? ........................... 93 How do I fix the program? ............................ 98 Exercises ..................................... 98 Chapter 18. Functions ...............................100 Creating Functions ................................ 100 Variables in functions .............................. 102 More complex example .......................... 102 Examples ..................................... 104 Exercises ..................................... 106 Chapter 19. Lists ..................................107 CONTENTS 7 Variables with more than one value ...................... 107 More features of lists ............................... 108 Examples ..................................... 113 Exercises ..................................... 115 Chapter 20. “For” Loops ..............................116 Exercises ..................................... 120 Chapter 21. Booleans ...............................121 Examples ..................................... 125 Exercises ..................................... 126 Chapter 22. File Input and Output . 127 Exercises ..................................... 128 Chapter 23. Introduce Python turtle . 129 Examples ..................................... 129 Exercises ..................................... 134 Chapter 24. Who Goes There-2, or GUI . 135 Exercises ..................................... 136 Chapter 25. Objects ................................137 Exercises ..................................... 140 Chapter 26. Python cheatsheet . 141 Homework 143 Chapter 27. Topics for self-study . 144 Chapter 28. Phylogeny Primer . 146 Some useful references ..............................147 Small foreword I use computer technologies for a long time, and learned many good stuff. To my amazement, I always perform routine work on the computer much faster then my colleagues. Therefore, I believe that if somebody will learn at least some of my meth- ods, they will perform computer-based work in a more efficient way. This is the goal of the “Computer literacy: make computer do the dirty work” book. I only want to mention that I am biologist and like command line and (very primi- tive!) programming. This explains some features of the book. Data Chapter 1 Text 1. Essentially, computer understands only numbers. Simple text interface was developed to make communication easier. Despite simplicity, it is extremely powerful and have much more capabilities then point and click graphical in- terface. 2. There are two main issues with simple text, line ends and encoding: (a) Line ends must be encoded as a separate invisible symbol(s). The way his- torically differ between operating systems: old Mac, Windows and UNIX. Most of text software is aware of these differences but there are some (like Windows Notepad) which do not do this job well. (b) Encoding regulates how many bytes are spend per symbol of text. There are (among others) 1 and 2 bytes encodings. (c) 1 byte encodings like ASCII or Latin-1 (ISO 8859-1) could only support 256 symbols, this is enough for core English but not enough for many world languages, especially if they used together. Actually, ASCII encodes only 7 128 symbols so it is /8-byte encoding. (d) 2 byte encodings like UTF-8 could support 256 × 256 = 65536 symbols which practically is enough for most of current languages together. (e) Some systems use 4 byte or 8 byte UTF-16 or UTF-32. The first is quite popular on Windows. (f) UTF-8 has one advantage over other multi-byte encodings: English letter are encoded like in ASCII. This is useful and saves traffic. (g) UTF-8 is one (of many) realizations of Unicode standard which covers all symbols which humanity developed during its history. (h) And one more detail: some computers read bytes from right to left (from second to first), and others from left to right. So UTF-8 text files havebyte 12 Text order mark (BOM) in the beginning of file. Sometimes, if BOM is acciden- tally absent, software could have troubles with UTF-8 encoded files. Text software There are many editors which are capable to work with simple text, i.e. text without formatting, which symbols only (including invisible ones like line ends, tabulation etc.) However, only few of them are really cross-platform (work on Windows, Linux and macOS) and even less are free and open source: • Geany. Fast, has many plug-ins which enhance it. • Kate. Part of the KDE environment but could be used separately. Exercise 1 Open the text editor, type or copy-paste