Chat with us, powered by LiveChat This homework tests your knowledge of File Handl - Writeedu

This homework tests your knowledge of File Handl

  1. This homework tests your knowledge of File Handling and use of Lists data type.
  2. Adhere to the naming conventions discussed in class for variable names, program name and function names
  3. Use meaningful names for variables, functions etc
  4. If there are two words in the variable use first word lowercase and first letter of second word upper case i.e., firstName or underscore between 2 words i.e first_name
  5. Include appropriate comments in the code
  6. Output should be displayed similar to as mentioned against each problem
  7. Indent the lines of code appropriately

1. Write and read file

a ) write_num.py (30 points)

Create a num_list file to write a range of numbers from 1 through 101.

Hints:

   Define main ():

   Open a file named as num_list in write mode.

   Use for loop to write a range of numbers from 1 through 101 into the file.

   Close file

b)read_num.py (40 points)

Use num_list file which got created in number 1.a. Write a program that will prompt the user to enter the name of the file (i.e. num_list.text), and display the first 10 lines of the file’s content. Use try/except construct to capture any file opening related errors such as invalid file name etc.

Hints:

                   Define main ():

                   Declare variables: line and counter, and initialize them

                   Prompt for file name: use input function

                   Open the file in read mode.

                   Read the lines in the file with readline function: ‘inline.readline()’ and initialize counter to 1

                   Use a while loop to read and display the first 10 lines

                                   Use rstrip method to remove n characters at the end of the line

                                   Print the line

                                   Update the counter when the line is read

                    Close file

Expected output:

Enter the name of the file: filename.txt

#

#

#

#

#

#

#

#

2. numanalysis.py (30 points)

Write a program that asks user to enter a series of 10 numbers. The program should store the numbers in a list then display the following data.

1. The list contents

2. The lowest number in the list

3.  The highest number in the list

4. The total of the number in the list

5. The average of the number in the list

Hints:

Define main ():

                       Declare variables and initialize them

                       Create an empty list 

                       Use the for loop with the range function to loop through 10 numbers. 

                       Prompt the User to enter the numbers from 1- 10. 

                           Ex: Enter number 1 of 10: 

                        Use append function to populate the  list

                        Use min, max, sum, functions to find the low , high and total number of the list.

                              Ex:  low = min(number_list)

                         Print the list contents

                        Print Low, high , total and average numbers of the list.

Expected output :

List: [#, #, #, #, #, #, #, #, #, #]

Low: #.##
High: #.##
Total: #.##
Average: #.##

    Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteEdu. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

    Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

    Do you need an answer to this or any other questions?

    Do you need help with this question?

    Get assignment help from WriteEdu.com Paper Writing Website and forget about your problems.

    WriteEdu provides custom & cheap essay writing 100% original, plagiarism free essays, assignments & dissertations.

    With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.

    Chat with us today! We are always waiting to answer all your questions.

    Click here to Place your Order Now