Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Write a Python(3.5.2) program that does the following. Create a function inputNumbers that uses a loop to allow the user to input 5 numbers between

Write a Python(3.5.2) program that does the following.

Create a function inputNumbers that uses a loop to allow the user to input 5 numbers between numbers between 1 and 10 and store them in an array called numArray. Call the function from def main().(20 points)

Create a function addNums that accepts numArray and uses a loop to add the numbers in the array. Call the function from def main(). Return the total to def main() and assign the total to a variable total. Display total (20 points).

Create a function writeArray that writes contents of the array to a file called Exam2.dat, one number per line. A new file should be created if a file called Exam2.dat currently exists. Call the function from def main() (20 points)

Create a function readArray that reads contents of the file and adds them. Return the total to def main(). Call the function from def main() (25 points)

Display the total of the numbers in def main(). (5 points)

Implement the pseudocode as shown (10 points):

Main module

//Call functions to input numbers. numArray = inputNumbers()

//Call function to add numbers total = addNums(numArray)

Display The total of the numbers is, total

// Write array contents to a file. writeArray(numArray)

//Read and display numbers in the file readArray()

End of main module

Sample Input/Output

Please enter 5 numbers between 1 and 10:

5 7 8 2 3

The total of the numbers is 25.

Writing numbers to a file

Reading numbers from a file

The numbers are:

5 7 8 2 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students explore these related Databases questions