Q: What is the average value of the following Python code snippet? >>>grade1 = 80 >>>grade2 = 90 >>>average = (grade1 + grade2) / 2
Solution: Cause a decimal value of 0 to appear as output.
Q: Select all options that print. hello-how-are-you
Solution: Execute in the shell.
Q: What is the return value of trunc()?
Solution: Execute help(math.trunc) to get details.
Q: What is the output of print 0.1 + 0.2 == 0.3?
Solution: Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary. The round off errors from 0.1 and 0.2 accumulate and hence there is a difference of 5.5511e-17 between (0.1 + 0.2) and 0.3.
Q: Which of the following is not a complex number?
Solution: l (or L) stands for long.
Q: What is the type of inf?
Solution: Infinity is a special case of floating point numbers. It can be obtained by float(‘inf’).
Q: What does ~4 evaluate to?
Solution: ~x is equivalent to -(x+1).
Q: What does ~~~~~~5 evaluate to?
Solution: ~x is equivalent to -(x+1). ~~x = – (-(x+1) + 1) = (x+1) – 1 = x ~~x is equivalent to x Extrapolating further ~~~~~~x would be same as x in the final result. In the question, x value is given as 5 and “~” is repeated 6 times. So, the correct answer for “~~~~~~5” is 5.
You Have Score    | /8 |