- Semantics:
- assignment:
- When assigning a variable to another name, eg,
a = b
, a new object is created. However, no data is copied due to the [copy-on-modify][ref1]
- When assigning a variable to another name, eg,
- In order to
xor
booleans, usexor(a, b)
. - reminder and quotient
%%
for reminder and%/%
for quotient.
- For accessing
list
insidelist
,[[index]]
must be used. - For returning a vector from a
data.frame
ordata.table
,df[[one_list_index]]
must be used. - slicing:
- assignment:
- Slicing happens when you
[]
a container (vector
,list
, etc) using more than one index, generated byseq
or:
orc()
. The index used can be integers or charaters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
# rowList is a list who the first and last element is 0(which will not be printed) | |
def print_pascal_triangle_row(row): | |
print(" ".join([str(each) for each in row[1 : -1]])) | |
# @parm n denotes how many rows should it print | |
def print_pascal_triangle(n): |
NewerOlder