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

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

Roztwór

Daniel veterano · Tutor durante 10 años
Weryfikacja ekspertów
4.1 (333 Votos)

Respuesta

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.Here are two possible code segments that can achieve this:Option 1:```pythonif score > 100: bonus = score * 10elif score >= 50: bonus = scoreelse: bonus = 0```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.Option 2:```pythonif score > 100: bonus = score * 10elif score >= 50: bonus = scoreelse: bonus = 0```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.Both options 1 and 2 correctly assign the bonus based on the value of score.