If/Else Programming (Ignore indents for the program)

What is the result of the following code when initiated?

brilliant = 1000
other = 100
if brilliant > other:
result = "b"
elif other > brilliant:
result = "o"
if result == "b":
winner = "b"
elif result == "o":
winner = "o"
if winner == "b":
print("Brilliant!")
elif winner == "o":
print("Not Brilliant!")

Do not run this code to find the answer

Nothing Not Brilliant! Error in code Brilliant!

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

This code means: If the number brilliant is assigned to is greater than the other number (if 1000 is greater than 100) set result to 'b'. Otherwise set result to 'o'. If result is 'b', set winner to 'b'. Otherwise, set winner to 'o'. If winner is 'b', say: Brilliant!. Otherwise, say: Not Brilliant! The result will be: Brilliant! You can test this in the 'coding environment' above the 'log-out' option.

Note that for the program to run, you must indent before every line without an if or elif (excluding the declaration of the initial brilliant and other variables). The indents are not included in question to prevent individuals from copying the code in the coding environment to find the answer.

§martie On Brilliant - 1 year, 3 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...