Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python You will require to read data from a file and perform operations on the data Create a file named csc101.py 1. Using the open

Python

You will require to read data from a file and perform operations on the data

Create a file named csc101.py

1. Using the open function in python, read the file info.txt. You MUST use try/except for error handling. If the file is not found, show a message that says "File not found"

2. Read the data from the file using readlines() method. Make sure to close the file after reading it

3. Take the data and place it into a list. The data in the list will look like the list below

['CSC 101 ', 'BMCC ', ' ', 'Good luck on your project! ', ' ', 'name ', ' ', 'email ', 'dog ', 'deer ', 'lion ', 'bear ', ' ', 'horse ', 'cow ', 'leopard ', 'whale ']

4. Create a function called remove_new_line_char_from_list(list) that removes all the items from the list. You can use the pop() method with looping. https://www.w3schools.com/python/ref_list_pop.asp TAB Correctly i = 0 ls = your list while i < len(ls): if ls[i] == " ": ls.pop(i) i += 1

5. Create a function called remove_new_line_char_from_string(list) that loops over the list and remove the new line character ( ) from each string

6. Create a function called modify_name that finds(list, your_name) "name" and replace it with your full name

All functions you were asked to create must take the list as an argument. These functions do not have a return value. Your functions will modify the list of items. You can always print the list to ensure your code modified the list in each function.

-----------------------------------------------------info.txt-------------------------------------------------------------

CSC 101

BMCC

Good luck on your project!

name

email

dog

deer

lion

bear

horse

cow

leopard

whale

-----------------------------------------------------info.txt-------------------------------------------------------------

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

Step: 3

blur-text-image

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

Database And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions

Question

Why We Form Relationships Managing Relationship Dynamics?

Answered: 1 week ago