program6_2.py Write another program named program6_2.py that uses a loop to read and process tests.txt from program6_1.py. The program must output a two-column table (see SAMPLE OUTPUT) showing the test names and scores. When the table is complete, the average should be displayed accurate to one decimal place. SAMPLE OUTPUT Reading six tests and scores TEST SCORE objects 88 loops 95 selections 86 variables 82 files 100 functions 80 Average is 88.5
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
hello! I just need help with the second portion program6_2.py. I will attached the question program6.2.py for reference. Please use pseudocode to explain your code. Any help is appreciated! Thank you so much!!
program6_2.py
Write another program named program6_2.py that uses a loop to read and process tests.txt from program6_1.py. The program must output a two-column table (see SAMPLE OUTPUT) showing the test names and scores. When the table is complete, the average should be displayed accurate to one decimal place.
SAMPLE OUTPUT
Reading six tests and scores
program6_1.py
Write a program named program6_1.py that prompts the user to enter six test names and their scores and writes them to a text file named tests.txt. You must use a loop. Each input should be written to its own line in the file. The program should generate a confirmation message when done. See SAMPLE OUTPUT.
SAMPLE OUTPUT
Entering six tests and scores
def main():
file = open("texts.txt","d")
print("THETEST \t\t SCORE")
count = 0
sum = 0
for line in file:
thetestScore = line.split()
sum = sum+int(thetestScore[1])
print(thetestScore[0], end='')
#this statement refers to Space indentation
for i in range(1,15-len(thetestScore[0])):
print (" ", end='')
print(thetestScore[1])
count += 1
if(count > 0):
average = round(sum/count, 1)
print("\nAverage: " + str(average))
else:
print("\nAverage: 0.0")
if __name__ == "__main__":
main()
Trending now
This is a popular solution!
Step by step
Solved in 2 steps