Python supports several forms of slicing. Assume that vector is defined below (2
ID: 3810264 • Letter: P
Question
Python supports several forms of slicing. Assume that vector is defined below (2, 4, 6, 8, 10, 12, 14, 16) What is the value of vector (0:7:2)? Assume that a C array has been declared as follows int a[3][5] Assume that the address of a is 1000, and int values occupy four bytes. What is the a address of a [2][4]? Negative subscripts are allowed in Perl. Assume an array @list has five elements which are 1, 2, 3, 4 and 5 respectively. What is value of @list(-1)? Assume an enumeration type colors and a variable mycolor of colors type are defined as below in C++: enum colors (red, blue, green, yellow, black); colors mycolor = blue; If there is another statement mycolor++, what value will be assigned to mycolor after the execution of this statement? Variables can be divided into four categorites: static, stack-dynamic, explicit heap-dynamic, and implicit heap-dynamic. Consider the following C++ code: int a; int f1 () {static int b; char *c = new char (5);} Specify which variable belongs to static, and which belongs to explicit heap-dynamic?Explanation / Answer
1) [ 2, 6, 10, 14]
Here in [0:7:2] '0' suggests strat from 0th element, '7' Suggests end at (7-1 ) 6. '2' suggests print every other number.
2) a[2][4] will be at memory address 1056.
3) list[-1] gives the last element that is 5
4) This gives a compilation error because enum value cannot be incremented
5) variable b belongs to static, variable *c belongs to explicit heap dynamic
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.