Select the missing comparison operator for the following Python code that prints a countdown from 10 to 0 inclusive. x = 10 while x /* Missing operator */ 0: print(x) x = x − 1 print("Blast off!") == != >= <=
If you know a person's name, there are a finite number of possibilities to obtain their credit card number. The expiration date on a card only slightly complicates the problem, given how fast modern computers can work. Which of the following is the least invasive way the merchant's website can protect credit card owners from malicious users? Asking for more personal information Calling users to verify the purchase Limiting the number of incorrect trials Recording users' IP addresses
Another question I was thinking either the first one or last one
The word "invasive" is throwing me off
@ultrilliam
@smokeybrown
For the question about the countdown and the missing operator, you want the countdown to keep going from 10, all the way down to 0 (including 0). So, the while loop needs to keep repeating as long as x is greater than or equal to 0. We can see what would happen for each of the operators: While x == 0: The program would go through the loop only if x is equal to 0, but x is set to 10 before this. Nothing inside the loop would be performed, and only "Blast off!" would be printed. While x != 0: The program would go through the loop whenever x is NOT equal to 0. This would cause the loop to keep running while x is equal to 10, 9, 8, and so on... but then when x is equal to 0, the loop would stop running. So, we would get a countdown from 10 to 1, and then "Blast off!" but the question asks for a countdown from 10 to 0, so this answer isn't completely correct. While x >= 0: The program would go through the loop whenever x is greater than or equal to 0. This would cause the loop to keep running while x is equal to 10, 9, 8, and so on, up to and including 0. The result is a countdown from 10 to 0, then "Blast off!" which is exactly what we want to happen. While x <= 0: The program would go through the loop only if x is less than or equal to 0, but x is set to 10 before this, which is not less than or equal to 0. Nothing inside the loop would be performed, and only "Blast off!" would be printed.
Well done :) I'm happy to help
Do you think you can help me with a few more if not thats fine
Join our real-time social learning platform and learn together with your friends!