ISEexchange / Python-Bootcamp

Discussion/Materials regarding the Python Bootcamp class
3 stars 7 forks source link

File Manipulation Lab/HW Week - 1 #1

Open jwasserzug opened 10 years ago

jwasserzug commented 10 years ago

Today we went over the basic concepts of Python using the Python Cheat Sheet located on the test servers at:

/home/python_bootcamp/python_cheat_sheet.py

Lab Assignment:

Define a function which searches through a file and checks for the presence of a specified string.
If there are any occurrences of this string, the function should return True, otherwise False.
The function should also print every line in which this string is present.

HW Assignment:

Create a new function: get_lines_in_file_with_string(file_name, search_string)
- This function will search through a target file for a specified search_string and return a list containing every line where the string is present.
- Print the number of lines containing the search_string
- Please remove all new line characters at the end of each line

BONUS Assignment:

Modify your verify_string_in_file() function to also support the following:
- When printing the line, print the line number as well
- Add a 3rd parameter for case sensitivity, by default, the function should be case sensitive (case_sensitive=True)
- Print the number of lines that contain the search_string
- Add any other printing or functionality you believe would improve the keyword.
- Best keyword will be added to the ASGLibrary (http://asg.ise.com/tap/ASG_Library_Keywords_Docs.html).
You will also be credited for your work in the comments of the code
- Please e-mail myself and Carlos with your function before next class

@vraghunandan @bdambola @kwokman @dsapienza @DRozentsvay @gganeshan @cbautista1002 @xingj53 @wcorrea @rklotz @isehgu @akbamaa