answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MariettaO
2 months ago
7

Exercise 8.1.9: Diving Contest Your school is hosting a diving contest, and they need a programmer to work on the scoreboard! Yo

ur job is to calculate each diver's total after the three judges hold up their individual scores. Write the function calculate_score which takes a tuple of three numbers from 0 to 10 and calculates the sum. A perfect dive is worth 30 points, a belly flop is worth 0. For example: calculate_score((10, 10, 10)) # => 30 calculate_score((9, 9, 6)) # => 24 can someone help?
Computers and Technology
1 answer:
zubka84 [1K]2 months ago
4 0

Response:

def calculate_score(theTuple):

    first, second, third = theTuple

    if first >= 0 and first <=10 and second >= 0 and second <=10 and third >= 0 and third <=10:

         print(first + second + third)

    else:

         print("Range must be 0 to 10")

Clarification:

This line initiates the function

def calculate_score(theTuple):

This line extracts the values used in the function

    first, second, third = theTuple

The subsequent if statement verifies whether the values fall within the 0 to 10 range

    if first >= 0 and first <=10 and second >= 0 and second <=10 and third >= 0 and third <=10:

This computes the total score

         print(first + second + third)

else:

Should the scores be outside the 0 to 10 limits, this line will be executed

         print("Range must be 0 to 10")

You might be interested in
When long labels are required, which of these commands can you use to improve readability of a worksheet?
maria [1035]
I think it's text wrapping! I hope this assists you.
6 0
1 month ago
Read 2 more answers
Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future" (without quotes). Els
Natasha_Volkova [1026]
Here's a C code snippet: #include <stdio.h> int main() { int year; printf("enter year:"); scanf("%d",&year); if(year>=2101) { printf("Distant future"); } else if(year>=2001&&year<=2100) { printf("21st century"); } else if(year>=1901&&year<=2000) { printf("20th century"); } else if(year<=1900) { printf("Long ago"); } return 0;} Output: enter year:2018 21st century. </stdio.h>
7 0
1 month ago
Read 2 more answers
You just read an msds for acetic acid. based on what you read, what type of information is included in an msds sheet? record you
maria [1035]
The MSDS sheet is packed with details such as the owning company of the acid, the ingredient's makeup, potential hazards and their management, first aid steps, and firefighting precautions, among other things. It provides comprehensive information necessary for laboratory safety when handling various chemicals. 
3 0
1 month ago
For any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a space. Ex: I
ivann1987 [1066]

Answer:

import java.util.Scanner;  //as referenced in the prompt.

public class ArraysKeyValue {  //as mentioned in the prompt.

public static void main (String [] args) {  //as stated in the prompt.

final int SIZE_LIST = 4; //as indicated in the prompt.

int[] keysList = new int[SIZE_LIST]; //as specified in the prompt.

int[] itemsList = new int[SIZE_LIST]; //as outlined in the prompt.

int i; //as identified in the prompt.

keysList[0] = 13; //as mentioned in the prompt.                                

keysList[1] = 47; //as stated in the prompt.

keysList[2] = 71; //as described in the prompt.

keysList[3] = 59; //as referenced in the prompt.

itemsList[0] = 12; //as mentioned in the prompt.

itemsList[1] = 36; //as stated in the prompt.

itemsList[2] = 72; //as specified in the prompt.

itemsList[3] = 54;//as indicated in the prompt.

// additional line needed to finalize the solution is as follows--

for(i=0;i<(keysList.length);i++) //Loop to access each element of keysList array variable.

    {// open for loop braces

        if(keysList[i]>50) // compare the values of keysList array variable with 50.

        System.out.println(itemsList[i]); // print the value

   }// close for loop braces.

}//  close main function braces.

} //close class braces.

Output:

72

54

Explanation:

In the resolution section--

  1. A single loop is engaged that iterates from 0 to (size-1) of the 'keyslist' array.
  2. The 'if' statement checks whether the 'keyslist' array's element exceeds 50 or not.
  3. If it does, the respective 'i' indexed item from the item_list array is printed as well, which corresponds to the higher value of the keyslist array element.

5 0
1 month ago
FOREACH, EXPLODE and MAIL are examples of crazy functions.
zubka84 [1067]
The selected response is B
4 0
2 months ago
Other questions:
  • print_pattern() prints 5 characters. Call print_pattern() twice to print 10 characters. Example output: ***** ***** in python
    7·1 answer
  • To reduce costs and the environmental impact of commuting, your company decides to close a number of offices and to provide supp
    14·1 answer
  • The part of the computer that contains the brain, or central processing unit, is also known as the A.monitor B.modem C.keyboard
    10·1 answer
  •  How does critically analyzing technology add value to interactions with people in personal and professional contexts?
    9·2 answers
  • Strlen("seven"); what is the output?
    14·1 answer
  • RADIAC instruments that operate on the ionization principle are broken down into three main categories based on what?
    15·1 answer
  • If a database named Contacts has a table named tblEmployees and another database named Orders links to that tblEmployees table,
    8·1 answer
  • JAVA Write a program that first asks the user to type a letter grade and then translates the letter grade into a number grade. L
    9·1 answer
  • Which of the following is true of how packets are sent through the internet?
    10·2 answers
  • A binary search can be performed only on ____.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!