Edited, memorised or added to reading list

on 12-Oct-2018 (Fri)

Do you want BuboFlash to help you learning these things? Click here to log in or create user.

Flashcard 3415723871500

Question
In python, you have sets, s={1,2,3} and t={1}, check (expect True) if all items in t are also in s.
Answer: s. [...] (t)
Answer
s.issuperset(t)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 3415955344652

Question
In regular expressions, using grep, match for the words kremlin, krypton, krn, krzn, in file test.txt?
Answer
grep -w 'kr.*n' test.txt
^^ note the use of "." followed by "*" to search for 0 or more of any char

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
5. Regular Expressions
-w 'cr[a-m]*t' Matches the words craft , credit , and cricket . The * means to match any number of the previous character, which in this case is any character from a through m . grep -w 'kr.*n' <span>Matches the words kremlin and krypton , because the . matches any character and the * means to match the dot any number of times. egrep -w '(th|sh).*rt' Matches the words shirt , short , and thwart . The | means to match ei







Flashcard 3416061775116

Question
In algorithms, between recurtion and iteration, which one is usually more processor intensive (hint: thing of case where it fails to terminate/is infinite)?
Answer
interation

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 3416064920844

Question
In algorithm, time complexity is measured in [...] notation
Answer
big-O
^^ FYI, O stands for Order-magnitude

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 3416093232396

Question
In algorithms, what is the big-O time complexity of an algorithm that shrinks the input size in half on each iteration (e.g. finding an element in a sorted array)?
Answer
O(logn)
^^ note that logn is, log base2 n

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 3416096378124

Question
In algorithms, what is the time complexity of iterating through all items in a single loop?
Answer
O(n)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 3416099523852

Question
In algorithms, what is the big-O time complexity of merge sort?
Answer
O(nlogn)
^^ you are reducing the input size by half on each recursion cycle (so logn), and on each merge you are iterating through whole list (so n) so n*logn

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 3416102669580

Question
In algorithms, what is the big-O time complexity of an algorithm that has nested loops (loop within a loop)?
Answer
O(n^2)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 3416105815308

Question
In algorithms, what is the big-O time complexity of an algorithm that has triple nested loop (loop in a loop in a loop)?
Answer
O(n^3)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

pdf

cannot see any pdfs







Flashcard 3419843202316

Question
In python 2, what is the easy way to sort a list, using "sorted" method, using a custom comparison function (for example, how to sort release_numbers = [1.2, 4.4.4, 1.2.1], using custom "compare" function that compares 1.2 to 1.2.1)?
Answer
sorted(release_numbers, cmp=compare)
^^ note the cmp arg is unique to python 2 and takes a custom compare function to use in sort.

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill






Flashcard 3419845823756

Question
In python 3, what is the easy way to sort a list, using "sorted" method, using a custom comparison function (for example, how to sort release_numbers = [1.2, 4.4.4, 1.2.1], using custom "compare" function that compares 1.2 to 1.2.1)?
Answer
sorted(release_numbers, key=functools.cmp_to_key(compare))
^^ note, in python 3, sorted does not have the cmp argument so you have to use the key argument via the functools.cmp_to_key conversion method)
^^ note 2, make sure you have "import functools" in your code

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill






Flashcard 3419848445196

Question
In python2, for the sorted and list.sort functions, what is the difference between the key argument vs the cmp argument?
Answer
key does a comparison against some derivitive of the list values being compared (e.g. len, for length) whereas cmp uses a custom functions to compare the whole of the two list items being compared (e.g. comparing release number 1.2 and 1.2.1 via a custom function)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill






Flashcard 3419851066636

Question
In python, you have file called "test.txt", write code to print out all the lines from "test.txt" and use approach where you have to close the file handle explicitly.
Answer
f = open("test.txt")
for line in f:
   print line
f.close()


statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill






Flashcard 3419855260940

Question
In python, you have file called "test.txt", write code to print out all the lines from "test.txt" and use approach where you do not need to worry about closing file handles.
Answer
with open("test.txt") as f:
    for line in f:
        print line

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill






Flashcard 3419857882380

Question
In python, if you are at the REPL (python interactive shell), and you want to know more about a method (use "sorted" method as example) like its signiture, how do you get this info?
Answer
help(sorted)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill






Flashcard 3419860503820

Question
In Linux, the keyboard shortcut for EOF (end of file), to exit the shell prompt for example (or exit the python REPL) is what?
Answer
ctrl-d

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill






Flashcard 3419864435980

Question
In Linux, what is the text editor that is the most common and available by default in all distros?
Answer
vi

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
6. Editing Text Files
an ordinary text file is known as text editing. A word processor is a kind of editor, but more basic than that is the UNIX or DOS text editor. 6.1 vi The important editor to learn how to use is <span>vi . After that you can read why, and a little more about other, more user-friendly editors. Type simply, vi <filename> to edit any file, or the compatible, but more advanced vim &lt







Flashcard 3419868105996

Question
In linux, what does the "m" in the "vim" text editor stand for?
Answer
vi "improved"

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
6. Editing Text Files
ow to use is vi . After that you can read why, and a little more about other, more user-friendly editors. Type simply, vi <filename> to edit any file, or the compatible, but more advanced <span>vim <filename> To exit vi , press , then the key sequence :q! and then press . vi has a short tutorial which should get you going in 20 minutes. If you get bored in the middle, you ca







Flashcard 3419871251724

Question
In Linux, the vi text editor has two modes, [...] mode and control mode
Answer
input

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
6. Editing Text Files
an read why, and a little more about other, more user-friendly editors. Type simply, vi <filename> to edit any file, or the compatible, but more advanced vim <filename> To exit vi , <span>press , then the key sequence :q! and then press . vi has a short tutorial which should get you going in 20 minutes. If you get bored in the middle, you can skip it and learn vi as you need t







Flashcard 3419874397452

Question
In Linux, the vi text editor has two modes, input mode and [...] mode
Answer
control

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
6. Editing Text Files
an read why, and a little more about other, more user-friendly editors. Type simply, vi <filename> to edit any file, or the compatible, but more advanced vim <filename> To exit vi , <span>press , then the key sequence :q! and then press . vi has a short tutorial which should get you going in 20 minutes. If you get bored in the middle, you can skip it and learn vi as you need t







Flashcard 3419877543180

Question
In Linux, for the vi editor, what key do you press to exit from control mode to input mode (and viceversa)?
Answer
ESC

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
6. Editing Text Files
a little more about other, more user-friendly editors. Type simply, vi <filename> to edit any file, or the compatible, but more advanced vim <filename> To exit vi , press , then the <span>key sequence :q! and then press . vi has a short tutorial which should get you going in 20 minutes. If you get bored in the middle, you can skip it and learn vi as you need to edit things.







Flashcard 3419880688908

Question
In python, for the vi editor, when in control mode, what do you type to force quit (quit without saving)?
Answer
:q!

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
6. Editing Text Files
about other, more user-friendly editors. Type simply, vi <filename> to edit any file, or the compatible, but more advanced vim <filename> To exit vi , press , then the key sequence <span>:q! and then press . vi has a short tutorial which should get you going in 20 minutes. If you get bored in the middle, you can skip it and learn vi as you need to edit things. To read the t







Flashcard 3419883834636

Question
In Linux, for the vi editor, if you are in control mode, how do you save and quit?
Answer
:wq

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
6. Editing Text Files
art insert mode. O Insert a blank line above the current line and then start insert mode. a Append (start insert mode after the current character). R Replace (start insert mode with overwrite). <span>:wq Save (write) and quit. :q Quit. :q! Quit forced (without checking whether a save is required). x Delete (delete under cursor and copy to register). X Backspace (delete left of cursor an







Flashcard 3419888291084

Question
In linux, what is the first line you use to start any shell script?
Answer
#!/bin/sh
^^ also accpetable: #!/bin/bash
^^ note there is no whitespace, and note that we are using the shebang (#!) syntax to indicate what program will be used to run the script (e.g. /bin/sh)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
7. Shell Scripting
Edit the file using your favorite text editor. The first line should be as follows with no whitespace. [Whitespace are tabs and spaces, and in some contexts, newline (end of line) characters.] <span>#!/bin/sh The line dictates that the following program is a shell script, meaning that it accepts the same sort of commands that you have normally been typing at the prompt. Now enter a number of







Flashcard 3419891961100

Question
In Linux, what does the #! syntax do when you put it at the top of any type of script/code?
Answer
It tells linux what program to use (full path) to run the script (e.g. #!/bin/sh for shell script, #!/usr/bin/python3 for python, etc)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
7. Shell Scripting
Edit the file using your favorite text editor. The first line should be as follows with no whitespace. [Whitespace are tabs and spaces, and in some contexts, newline (end of line) characters.] <span>#!/bin/sh The line dictates that the following program is a shell script, meaning that it accepts the same sort of commands that you have normally been typing at the prompt. Now enter a nu







Flashcard 3419895106828

Question
In Linux, in a shell script, how do you create a variable, x, and assign to it the value, 2?
Answer
x=2

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
7. Shell Scripting
keyboard into that pigeonhole. Thereafter, whenever the shell encounters NM , its contents are written out instead of the letters NM (provided you write a $ in front of it). We say that NM is a <span>variable because its contents can vary. You can use shell scripts like a calculator. Try 5 echo "I will work out X*Y" echo "Enter X" read X echo "Enter Y" read Y echo "X*Y = $X*$Y = $[X*Y]" The







Flashcard 3419898252556

Question
In linux, you have a shell script with line "x=2", how do you print out the value of x
Answer
echo $x
^^ note the $ syntax does parameter/variable expansion, i.e. accesses the value of x, without it just "x" gets printed

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
7. Shell Scripting
, and then inserts text read from the keyboard into that pigeonhole. Thereafter, whenever the shell encounters NM , its contents are written out instead of the letters NM (provided you write a <span>$ in front of it). We say that NM is a variable because its contents can vary. You can use shell scripts like a calculator. Try 5 echo "I will work out X*Y" echo "Enter X" read X echo "En







Flashcard 3419902184716

Question
In Linux, in shell scripts, the $[] syntax is called [...] [...]
Answer
expression expansion
^^ e.g. is: echo $[2*6], which would print "12" to the screen

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
7. Shell Scripting
variable because its contents can vary. You can use shell scripts like a calculator. Try 5 echo "I will work out X*Y" echo "Enter X" read X echo "Enter Y" read Y echo "X*Y = $X*$Y = $[X*Y]" The <span>[ and ] mean that everything between must be evaluated [Substituted, worked out, or reduced to some simplified form. ] as a numerical expression [Sequence of numbers with + , - , * , etc. betwe







Flashcard 3419905330444

Question
In Linux, you have shell script, that has already defined x=2 and y=3, how do you print out the sum of x and y?
Answer
echo $[x+y]

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
7. Shell Scripting
variable because its contents can vary. You can use shell scripts like a calculator. Try 5 echo "I will work out X*Y" echo "Enter X" read X echo "Enter Y" read Y echo "X*Y = $X*$Y = $[X*Y]" The <span>[ and ] mean that everything between must be evaluated [Substituted, worked out, or reduced to some simplified form. ] as a numerical expression [Sequence of numbers with + , - , * , etc. betwe







Flashcard 3419908476172

Question
In Linux, in shell scripting, the $ syntax is called [...] [...]
Answer
variable expansion

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill
7. Shell Scripting
We say that NM is a variable because its contents can vary. You can use shell scripts like a calculator. Try 5 echo "I will work out X*Y" echo "Enter X" read X echo "Enter Y" read Y echo "X*Y = <span>$X*$Y = $[X*Y]" The [ and ] mean that everything between must be evaluated [Substituted, worked out, or reduced to some simplified form. ] as a numerical expression [Sequence of numbers w







Flashcard 3419911621900

Question
In linux, in shell scripting, the $() syntax (e.g. $(pwd) ), is called [...] [...]
Answer
command expansion

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill






Flashcard 3419914243340

Question
In Linux, in shell scripting, how do you print out the value of the pwd command (e.g. /home/kevin would be printed if you are in home directory)?
Answer
echo $(pwd)

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill