Quiz
a = 3
b = 20
if b > a:
print("hey")
What is the output from the above statement
<question >
<p><pre><code>a = 10
b = 40 if a = b: print('equal') else: print('not equal') What is the output of the given code?
<question >
<p><pre><code>a = 10
b = 40 if (a != b): print(a) else: print(b) What is the output of the given code?
a = 10
if a:
print(a)
else:
print('a')
What is the output of the given code?
<question>
<p><pre><code>x = 20
message = '' if (x % 2 == 0): message += 'Nay' if (x % 5 == 0): message += "dah!" if (x % 2 == 0 and x % 5 == 0): message += "Yay" print(message)What is the output of the given code?
How would you change the above code to print only 'Yay' if the number 'x' is a multiple of 2 and 5 and 'Nay' when it is multiple of only 2 and 'dah!' when it is a multiple of only 5?
<question>
<p><pre><code>a = 5
b = 2 c = 20 d = 5 if c / a > b: b = b + c else: b = b + a
c = c * a - b / 2
if (b < c and d < a): d = d / 2 else: a = c - 3
if d % b == 0: d = c + a
if (c / 2 > b or d - a == b): d = d - 3
print(a, b, c, d) What is the output when the below program is run?
<answer correct>86.0 22 89.0 2</answer>
<answer>86 22 89 2</answer>
<answer>86.0 2 89.0 2</answer>
<answer>86.0 22 89.0 5</answer>
<explanation> Remeber to apply PEMDAS rules. It does not hurt to write down the variable values on a piece of paper in a tabular form, after every statement to keep track of how they all are changing or not after every statement is executed.</explanation>
</question>
##Exercise