What is a variable in context of programming?
A single letter or sequence of letters and symbols, that act as place holder for one or more values of different types, that are stored on the computer.
What is a data container?
the storage types of variables
scalar: single value
vector, matrix, array: many values, one type; individual value accessable by number(s)
list/dictionary: many values, one or more types; individual value accessable by number or key
For an array defined as arr = [1,2,3,4] R and python give a different output to arr[1]
arr = [1,2,3,4]
arr[1]
Why is this the case?
R starts indices with 1; python with 0, the out put would be 1 for R and 2 for python
1
2
What is the input for python and R, to get the output x is 3 ?
x is 3
x=3 is already defined
python: print(‘x is’,x)
print(‘x is’,x)
R: print(paste(‘x is’,x)
print(paste(‘x is’,x)
Why can’tyou name variables def, class, return, assert or pass?
They are reserved as names for keywords.
Why should you avoid to use T/F instead of TRUE/FALSE in R?
Despite T and F are equal to TRUE and FALSE, they can be overwitten with other values.
Last changed2 months ago