Pagina de inicio
/
Tecnología
/
16 In a certain game the integer variable bonus is assigned a value based on the value of the integer variable score. If score is greate than 100, bonus is assigned a value that is 10 times score. - If score is between 50 and 100 inclusive bonus is assigned the value of score. - If score is less than 50, bonus is assigned a value of Which of the following code segments assigns bonus correctly for all possible integer values of score? Select two answers. Mark for Review

Problemas

16
In a certain game the integer variable bonus is assigned a value based on the value of the integer
variable score.
If score is greate than 100, bonus is assigned a value that is 10 times score.
- If score is between 50 and 100 inclusive bonus is assigned the value of score.
- If score is less than 50, bonus is assigned a value of
Which of the following code segments assigns bonus correctly for all possible integer values of score?
Select two answers.
Mark for Review

16 In a certain game the integer variable bonus is assigned a value based on the value of the integer variable score. If score is greate than 100, bonus is assigned a value that is 10 times score. - If score is between 50 and 100 inclusive bonus is assigned the value of score. - If score is less than 50, bonus is assigned a value of Which of the following code segments assigns bonus correctly for all possible integer values of score? Select two answers. Mark for Review

Solución

avatar
Danielveterano · Tutor durante 10 años
expert verifiedVerificación de expertos
4.1 (333 votos)

Responder

To assign the bonus correctly for all possible integer values of score, we need to use conditional statements to check the value of score and assign the appropriate value to bonus.<br /><br />Here are two possible code segments that can achieve this:<br /><br />Option 1:<br />```python<br />if score > 100:<br /> bonus = score * 10<br />elif score >= 50:<br /> bonus = score<br />else:<br /> bonus = 0<br />```<br />In this code segment, we first check if score is greater than 100. If it is, we assign bonus the value of score multiplied by 10. If score is not greater than 100, we check if it is greater than or equal to 50. If it is, we assign bonus the value of score. Otherwise, we assign bonus the value of 0.<br /><br />Option 2:<br />```python<br />if score > 100:<br /> bonus = score * 10<br />elif score >= 50:<br /> bonus = score<br />else:<br /> bonus = 0<br />```<br />In this code segment, we first check if score is greater than 100. If it is, we assign bonus the value of score multiplied by 10. If score is not greater than 100, we check if it is greater than or equal to 50. If it is, we assign bonus the value of score. Otherwise, we assign bonus the value of 0.<br /><br />Both options 1 and 2 correctly assign the bonus based on the value of score.
Haz clic para calificar: