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
ludmilkaskok [199]
3 years ago
5

A teacher wants a program to give extra points to students who fail a test. Write a Python program to do the following: (a) Ask

the user to enter 5 test scores. Store the scores in a list. Display the list. (b) Copy all 5 test scores to another list. Use a loop to examine each test score in the new list. If the score is below 60, add 10 extra points to the score. Display the list. (c) Compare the old score and new score of each student. If the old score and new score are different, display the two scores.
Computers and Technology
1 answer:
Lorico [155]3 years ago
8 0

Answer:

Hi there! Please find the answer below.

Explanation:

The program below demonstrates how each of the requirements can be coded in a simple Python script. To copy the array, we can use the copy() method of the array. To calculate the diff, we can use a few different techniques, so I have implemented it using a loop over the arrays and just storing and displaying the difference in the 2 arrays.

new_string.py

def add_test_score(score):

 test_score.append(score);

contact_hash = {}

test_score = []

print("Enter 5 test scores: ");

for x in range(0, 5):

   input_string = input("Enter test score " + str(x + 1) + ": ")

   add_test_score(int(input_string));

print(test_score);

test_score_copy = test_score.copy();

for e in test_score_copy:

   if e < 60:

       test_score_copy[test_score_copy.index(e)] += 10;

diff = [];

for e in test_score:

   print(test_score[test_score.index(e)]);

   print(test_score_copy[test_score.index(e)]);

   if not test_score[test_score.index(e)] == test_score_copy[test_score.index(e)]:

       diff.append(e);

print(diff);

You might be interested in
When constructing policies regarding data _______________, it is important that these policies offer particular guidance on sepa
Rama09 [41]

Answer:

access

Explanation:

Managing users' access rights to digital resources within the organization's environment is a fundamental SoD control. As more services are requested by users, utilizing the built-in panels to check compliance with internal controls might become excessive. Companies require a comprehensive Identity Governance and Administration plan to monitor these user access and offer an authoritative source of identity definitions in order to ensure  SoD compliance.

6 0
2 years ago
Assume the variable myWord references a string. Write a statement that uses a slicing
givi [52]

Answer:

"myWord[-5:]"

Explanation:

So whenever you slice a string, the syntax in python is expressed as:

string[a:b:c]

where a=start index (this is included in the sliced string)

b = end index (this is excluded from the sliced string)

c = increment

If any of these are included, they are set to default values, where a=0, b=len(string), and c=1.

The increment isn't necessary here, and it's just so you know the syntax a bit more

Anyways, I'm assuming when the question asks to display "the last 5 characters in the string" it means in order? e.g "abcdefghijk" -> "ghijk" and not "abcdefghijk" -> "kjihg"

The last piece of information to know is what a negative index represents.

For example if I have the piece of code

"

string = "hello world"

print(string[-1])

"

This will output "d", and the negative 1 represents the last letter. If you did -2, it would output the 2nd to last letter and so on.

So to print the last 5 characters, we simply use the -5 as the starting index.  

"

string = "hello world"

print(string[-5:])

"

This will print "world" or in other words, the last 5 letters. The reason for this is because the -5 in the first spot means the starting index is the 5th to last letter, and when you have the : after the -5, this is the way of telling python you're slicing the string, and not indexing 1 character. You don't need to include another value after that, because it will default to the last index of the string, or more specifically the last index + 1, since the last index is still included.

So the last thing to know, is that if the string isn't greater than 5 characters, it just prints the entire string, and no errors are raised. You can test this out your self as well. So whenever you have a string that's less than 5 characters the entire string is outputted.

3 0
1 year ago
What is a blog that is set up for advertising purposes and used to send website links and other spam? A. splog B. adlog C. qlog
Alex_Xolod [135]

A. Splog. also known as "spam blog"

3 0
2 years ago
Read 2 more answers
Which concept allows the computer to repeat a group of steps in an
allochka39001 [22]

Answer:

A

Explanation:

I was gonna say 'loop' from my computing days. but it is now called iteration

7 0
1 year ago
Does anyone know how to fix this error of " the media could not be loaded, either because the server or network failed or becaus
enyata [817]

Answer:

Restart your WiFi!

Explanation:

It happened to me I did that and it fixed it

7 0
3 years ago
Read 2 more answers
Other questions:
  • Why does the PC send out a broadcast ARP prior to sending the first ping request
    12·1 answer
  • A network that typically reaches a few meters, such as up to 10 meters (33 feet), and consists of personal devices such as mobil
    14·1 answer
  • Should a waiting thread receive priority over a thread first attempting to enter a monitor? What priority scheme, if any, should
    9·1 answer
  • Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the
    7·1 answer
  • A small business has suffered from a cyber attack, what could be the resultant damage​
    10·1 answer
  • Write a Java application that uses the Math class to determine the answers for each of the following: a. The square root of 37 b
    10·1 answer
  • Question 3 of 10
    7·1 answer
  • What pointer appears when pointing to a hyperlink?
    9·1 answer
  • The owner of a candle shop has asked for your help. The shop sells three types of candles as shown below:
    14·1 answer
  • Select the correct answer
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!