PETE 2061 Exam Questions &
Answers (Grade A+)
What value will be displayed if these three lines of code are run?
ny = 4
nx, ny, nz = 4, 5, 10
print(ny) -
correct answer ✅5
The first line assigns 4 to ny. So, "ny" contains the value, 4.
The second line assigns 4 to nx, 5 to ny, and 10 to nz. (So, nx = 4, ny
= 5, and nz = 10)
The third line prints the value contained in ny, which is now 5 (It
was updated from 4 to 5 in the second line).
The commands below will display two lines of "Hello, World!".
print("Hello, World!")
,PETE 2061 Exam Questions &
Answers (Grade A+)
#print("Hello, World!") -
correct answer ✅False
The commands below will display two lines of "Hello, World!".
print("Hello, World!")
#print("Hello, World!")
When we neglect higher-order terms in the Taylor series expansion,
and obtain an expression for the derivative of a function (f(x)) with
respect to x. This is an example of a round-off error. -
correct answer ✅Neglecting the higher-order terms means
truncating the series expansion. So, this is a truncation error and
not a round-off error
The
correct answer is 'False'.
,PETE 2061 Exam Questions &
Answers (Grade A+)
What value will be displayed by the print statement when the
following line of code is run?
print(8//3) -
correct answer ✅2
Your answer is correct.
The code will display 2 because 8 divided by 3 is 2.6667, and this
gets rounded down to 2 because the "//" divides and rounds down
( or "floors") 2.6667 to the nearest lower whole number.
What value will be displayed by the print statement when the
following lines of code are run?
length, width, height = 5, 2, 1
reducedVolume = (length*width*height)*(9/10)
print(reducedVolume) -
correct answer ✅The first line of code assigns the length, width
and height to 5, 2, and 1, respectively.
, PETE 2061 Exam Questions &
Answers (Grade A+)
The second line of code multiplies the product of length, width and
height by 0.9 and stores the result (which is 5*2*1*9/10 = 9) into
the variable called "reducedVolume". Note that the parenthesis are
unnecessary in this case.
The last line prints 9 to the screen, because this is the value stored
in "reducedVolume".
The
correct answer is: 9
Which of the following is a valid variable name -
correct answer ✅oilDensity
What gets displayed on the screen when the following line of code
is run?
print("2*2") -
correct answer ✅2*2
Answers (Grade A+)
What value will be displayed if these three lines of code are run?
ny = 4
nx, ny, nz = 4, 5, 10
print(ny) -
correct answer ✅5
The first line assigns 4 to ny. So, "ny" contains the value, 4.
The second line assigns 4 to nx, 5 to ny, and 10 to nz. (So, nx = 4, ny
= 5, and nz = 10)
The third line prints the value contained in ny, which is now 5 (It
was updated from 4 to 5 in the second line).
The commands below will display two lines of "Hello, World!".
print("Hello, World!")
,PETE 2061 Exam Questions &
Answers (Grade A+)
#print("Hello, World!") -
correct answer ✅False
The commands below will display two lines of "Hello, World!".
print("Hello, World!")
#print("Hello, World!")
When we neglect higher-order terms in the Taylor series expansion,
and obtain an expression for the derivative of a function (f(x)) with
respect to x. This is an example of a round-off error. -
correct answer ✅Neglecting the higher-order terms means
truncating the series expansion. So, this is a truncation error and
not a round-off error
The
correct answer is 'False'.
,PETE 2061 Exam Questions &
Answers (Grade A+)
What value will be displayed by the print statement when the
following line of code is run?
print(8//3) -
correct answer ✅2
Your answer is correct.
The code will display 2 because 8 divided by 3 is 2.6667, and this
gets rounded down to 2 because the "//" divides and rounds down
( or "floors") 2.6667 to the nearest lower whole number.
What value will be displayed by the print statement when the
following lines of code are run?
length, width, height = 5, 2, 1
reducedVolume = (length*width*height)*(9/10)
print(reducedVolume) -
correct answer ✅The first line of code assigns the length, width
and height to 5, 2, and 1, respectively.
, PETE 2061 Exam Questions &
Answers (Grade A+)
The second line of code multiplies the product of length, width and
height by 0.9 and stores the result (which is 5*2*1*9/10 = 9) into
the variable called "reducedVolume". Note that the parenthesis are
unnecessary in this case.
The last line prints 9 to the screen, because this is the value stored
in "reducedVolume".
The
correct answer is: 9
Which of the following is a valid variable name -
correct answer ✅oilDensity
What gets displayed on the screen when the following line of code
is run?
print("2*2") -
correct answer ✅2*2