# on 14-Aug-2018 (Tue)

#### Annotation 3164471168268

 #strategy According to the skilled strategist Sun Tzu, strategy is about winning before the battle begins, while tactics are about striking at weakness.

#### Annotation 3164473003276

 #strategy “Strategy without tactics is the slowest route to victory. Tactics without strategy are the noise before defeat.”

#### Annotation 3169669745932

 20 CHAPTER 4. LATTICE BOLTZMANN expect that we need a 4 velocity model to fulfill the remaining 4 constraints. But if there was a way to reduce the number of required velocities further we could save some memory and computation time. If you now consider that you will not be interested in the absolute value of the temperature, you can use the determination of the temperature as an additional degree of freedom. You use the 4 equation to determine f 0 −1 , f 0 0 f 1 , and θ.

#### pdf

cannot see any pdfs

#### Annotation 3169674726668

 e know that the velocity has to be much smaller than the lattice velocity c = 1 and θ is nearly constant. Most standard lattice Boltzmann models use these smaller velocity sets. For models in an arbitrary number of dimensions this usually means that the third moment of the equilibrium distribution function is modified to

#### pdf

cannot see any pdfs

#### Annotation 3169683377420

 This description of the simulation of non-ideal fluids is quite superficial. In particular we have only considered the bulk terms of the pressure. There are additional terms which relate to the surface tension. Introducing a forcing of the form of (4.33) will lead to a surface tension

#### pdf

cannot see any pdfs

#### Annotation 3169707232524

 It is important to understand the scoping rules of variables inside functions. Each time a function executes, a new local namespace is created. This represents a local environment that contains the names of the parameters and variables that are assigned by the function. To resolve a namespace when a function is called, the Python interpreter first searches the local namespace (that is, the function itself) and if no match is found, it searches the global namespace. This global namespace is the module in which the function was defined. If the name is still not found, it searches the built-in namespace. Finally, if this fails then the interpreter raises a NameError exception. Consider the following code: a=10; b=20 def my_function(): global a a=11; b=21 my_function() print(a) #prints 11 print(b) #prints 20

#### pdf

cannot see any pdfs

#### Flashcard 3169709591820

Question
a=10; b=20
def my_function():
[...] a
a=11; b=21
my_function()
print(a) #prints 11
print(b) #prints 20
global

status measured difficulty not learned 37% [default] 0

#### Parent (intermediate) annotation

Open it
ame is still not found, it searches the built-in namespace. Finally, if this fails then the interpreter raises a NameError exception. Consider the following code: a=10; b=20 def my_function(): <span>global a a=11; b=21 my_function() print(a) #prints 11 print(b) #prints 20 <span>

#### Original toplevel document (pdf)

cannot see any pdfs

#### Flashcard 3169712737548

Question
If python interpretor finds undefined variable, it raises [...] exception.
NameError

status measured difficulty not learned 37% [default] 0

#### Parent (intermediate) annotation

Open it
. This global namespace is the module in which the function was defined. If the name is still not found, it searches the built-in namespace. Finally, if this fails then the interpreter raises a <span>NameError exception. Consider the following code: a=10; b=20 def my_function(): global a a=11; b=21 my_function() print(a) #prints 11 print(b) #prints 20 <span>

#### Original toplevel document (pdf)

cannot see any pdfs

#### Annotation 3169717718284

 Everything is an object in Python, including modules, classes, and functions, as well as literals such as strings and integers

#### pdf

cannot see any pdfs

#### Flashcard 3169720077580

Question
In python everything, including modules, classes, and functions, as well as literals such as strings and integers, is an [...]
object

status measured difficulty not learned 37% [default] 0

#### Parent (intermediate) annotation

Open it
Everything is an object in Python, including modules, classes, and functions, as well as literals such as strings and integers

#### Original toplevel document (pdf)

cannot see any pdfs

#### Annotation 3169724534028

 important distinction needs to be made between mutable and immutable objects. Mutable object's such as lists can have their values changed. They have methods, such as insert() or append(), that change an objects value. Immutable objects, such as strings, cannot have their values changed, so when we run their methods, they simply return a value rather than change the value of an underlying object. We can, of course, use this value by assigning it to a variable or using it as an argument in a function

#### pdf

cannot see any pdfs

#### Flashcard 3169726106892

Question
Immutable objects like strings, cannot have their values changed, so when we run their methods (like splice, with ":" notation), they simply [...] rather than change the value of the underlying object.
return a new value

status measured difficulty not learned 37% [default] 0

#### Parent (intermediate) annotation

Open it
d. They have methods, such as insert() or append(), that change an objects value. Immutable objects, such as strings, cannot have their values changed, so when we run their methods, they simply <span>return a value rather than change the value of an underlying object. We can, of course, use this value by assigning it to a variable or using it as an argument in a function <span>

#### Original toplevel document (pdf)

cannot see any pdfs

#### Flashcard 3169730039052

Question
In python, you have string, s, how do you get the index of first occurance of substring 'abc' in s (-1 is returned if 'abc' substring is NOT found)?
s.find('abc')

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169732398348

Question
Python string method to convert list of chars to string, e.g. ["a", "b", "c"] to "a b c"
" ".join(["a", "b", "c"])

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169734757644

Question
Python string method to convert string to all lowercase?
s.lower()

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169737116940

Question
Python string method that swaps out letters for other ones, e.g. "aabbaabb" to "aaccaacc"
"aabbaabb".replace("bb", "cc")

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169739476236

Question
Python string method that removes leading and ending whitespace (or any other chars), e.g. " abcd\n" to "abcd"
"abcd\n".strip()

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169741835532

Question
Python string method that converts a string to a list (based on given seperator), e.g. "a,b,c,d" to ["a", "b", "c", "d"]
"a,b,c,d".split(",")

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169744194828

Question
In Python, convert "abcdef" to "cdef"
"abcdef"[2:]

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169746554124

Question
In python add 5 to defined list = [1,2,3,4]
list.append(5)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169748913420

Question
In python add a list to another existing list, item by item, e.g. add [3,4,5] to list=[1,2] so value list will then be [1,2,3,4,5]
list.extend([3,4,5])

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169751272716

Question
In python, get the index of 2 in list = [1,2,3,4,5]
list.index(2)
(value will be 1)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169754418444

Question
In python insert 2 in to list = [1,3,4]
list.insert(1,2)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169756777740

Question
In python, list = [1,2,3,4], what does list.pop(1) do exactly (mention 2 results)
It returns 2 and changes list to [1,3,4]

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169759137036

Question
In python remove 2 from list = [1,2,3,4] by index!
list.pop(1)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169761496332

Question
In python remove 2 from list = [1,2,3,4] by value (i.e using 2)
list.remove(2)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169763855628

Question
In python list = [1,2,3,4], what is the return value of list.remove(2)?
None
Because lists are mutable so calling their methods will change the underlying list but return nothing.

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3169766214924

Question
Using python list comprehension convert list = [1,2,3,4] to new_list = [2,4,6,8]