1answer.
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
Nina [5.8K]
2 years ago
13

Write a program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name wil

l be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name. Write the following functions in the program: calc_average - this function should accept 8 test scores as arguments and return the average of the scores. determine_grade - this function should accept a test score average as an argument and return a letter grade for the score based on the following grading scale: 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F
Computers and Technology
1 answer:
sergeinik [125]2 years ago
3 0

Answer:

// program in Python

# function to find grade

def grade(t_score):

   #grade A

   if t_score >=90:

       return 'A'

       #grade B

   elif t_score >=80 and t_score <90:

       return 'B'

   #grade C

   elif t_score >=70 and t_score <80:

       return 'C'

   #grade D

   elif t_score >=60 and t_score <70:

       return 'D'

   #grade F

   else:

       return 'F'

# function to find average score

def calc_average(test_score):

   #variable to find sum

   total = 0

   for i in range(len(test_score)):

       #calculate total score

       total = total + test_score[i]

   # find average

   return total/float(len(test_score))

#array to store score

test_score = []

#read name of student

name = input("Enter student's name: ")

for i in range(8):

   #read score

   t_score = int(input("Enter the score {}: ".format(i+1)))

   #add score to array

   test_score.append(t_score)

#call function to find Average

averageScore = calc_average(test_score)

#print name of Student

print("Student Name: ", name)

#print each Score

for i in range(len(test_score)):

   #print each Score and Grade

   print("Score: ",test_score[i], "Letter Grade: ",grade(test_score[i]))

# print Average Score

print("Average Score: ", averageScore)

Explanation:

Read name of student from user.Then read 8 test scores from user. Call the function grade() to find the grade of a test score.Call the function calc_average() to  find the average score of all test.Print each score and corresponding grade and print  average score.

Output:

Enter student's name: Sam                                                                                                  

Enter the score 1: 45                                                                                                      

Enter the score 2: 98                                                                                                      

Enter the score 3: 67                                                                                                      

Enter the score 4: 86                                                                                                      

Enter the score 5: 60                                                                                                      

Enter the score 6: 77                                                                                                      

Enter the score 7: 92                                                                                                      

Enter the score 8: 32                                                                                                      

Student Name:  Sam                                                                                                        

Score:  45 Letter Grade:  F                                                                                                

Score:  98 Letter Grade:  A                                                                                                

Score:  67 Letter Grade:  D                                                                                                

Score:  86 Letter Grade:  B                                                                                                

Score:  60 Letter Grade:  D                                                                                                

Score:  77 Letter Grade:  C                                                                                                

Score:  92 Letter Grade:  A                                                                                                

Score:  32 Letter Grade:  F                                                                                                

Average Score:  69.625  

You might be interested in
Can some one help me answer this question plz
sergij07 [2.7K]

Answer:

In mathematics and digital electronics, a binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: typically "0" (zero) and "1" (one). The base-2 numeral system is a positional notation with a radix of 2. Each digit is referred to as a bit, or binary digit.

Explanation: and the key to reading binary is separating the code into groups of usually 8 digits and knowing that each 1 or 0 represents a 1,2,4,8,16,32,64,128, ect. from the right to the left. the numbers are easy to remember because they start at 1 and then are multiplied by 2 every time.

5 0
3 years ago
You are given an unsorted array x of elements that implement the Comparable interface. There are no duplicates in this array. Yo
Andrei [34K]

Answer:

boolean isEven = false;

if (x.length % 2 == 0)

isEven = true;

Comparable currentMax;

int currentMaxIndex;

for (int i = x.length - 1; i >= 1; i--)

{

currentMax = x[i];

currentMaxIndex = i;

for (int j = i - 1; j >= 0; j--)

{

if (((Comparable)currentMax).compareTo(x[j]) < 0)

{

currentMax = x[j];

currentMaxIndex = j;

}

}

x[currentMaxIndex] = x[i];

x[i] = currentMax;

}

Comparable a = null;

Comparable b = null;

if (isEven == true)

{

a = x[x.length/2];

b = x[(x.length/2) - 1];

if ((a).compareTo(b) > 0)

m = a;

else

m = b;

}

else

m = x[x.length/2];

8 0
3 years ago
Does anybody want to be my friend
Gekata [30.6K]

Answer:

Yeah sure, mines aatelophxbia, i'm 14. what games you play?

6 0
3 years ago
Read 2 more answers
What was named the worst game ever?
Schach [20]

Answer:

Fortnight

Explanation:

7 0
3 years ago
Read 2 more answers
Which of the following is a proprietary OS for desktop and loptop computers?<br><br>conguardelation
Travka [436]

Answer:

windows

Explanation:

windows is the best operating system for desktop and laptop

3 0
2 years ago
Other questions:
  • What term is used to describe a function that uses an algorithm to convert an input of letters and numbers into an encrypted out
    9·1 answer
  • What is the most recognized and widely used database of published nursing practice literature?
    15·1 answer
  • You are testing a web application for sql injection vulnerabilities. you send various sql statements which return results on the
    5·1 answer
  • Write a function called simulate_several_key_strikes. It should take one argument: an integer specifying the number of key strik
    7·1 answer
  • Match each scenario to the absolute value expression that describes it. 1. the distance moved when going backwards five spaces i
    13·2 answers
  • A host is on the 192.168.146.0 network that has a subnet mask of 255.255.255.0. The binary value of the host portion is 11010101
    8·1 answer
  • Write the function greeting that takes a string as input. That string will be formatted as Name Age Hobby, without any punctuati
    14·1 answer
  • In order to create a chart, which of the following must be selected?
    8·1 answer
  • Overheating of a computer can be easily prevented. Explain how​
    15·1 answer
  • Which of the following tabs on the Ribbon contains the command to add a Quick Part to a document? A Design B Insert C View D Hom
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!