Changes

Jump to: navigation, search

OPS435 Python Lab 5

83 bytes removed, 23:23, 10 September 2017
Create a Python Script Demonstrating Reading Files
=== Create a Python Script Demonstrating Reading Files ===
:'''Perform the Following Instructions'''::#Create the '''~/ops435/lab5/lab5a.py''' script. ::#Use the following as a template:<source lang="python">
#!/usr/bin/env python3
</source>
:::*This Python script will read the same file ('''data.txt''') that you previously created:::*The '''read_file_string()''' function should return a string:::*The '''read_file_list()''' function should return a list:::*The '''read_file_list()''' function must remove the new-line characters from each line in the list:::*'''Both functions must accept one argument''' which is a string:::*The script should show the exact output as the samples:::*The script should contain no errors
::::'''Sample Run 1:'''<source lang="python">
python3 lab5a.py
Hello World
</source>
::::'''Sample Run 2 (with import):'''<source lang="python">
import lab5a
file_name = 'data.txt'
['Hello World', 'This is the second line', 'Third line', 'Last line']
</source>
:::3. Exit the ipython3 shell, download the checking script and check your work. Enter the following commands from the bash shell.<source lang="bash">
cd ~/ops435/lab5/
pwd #confirm that you are in the right directory
python3 ./CheckLab5.py -f -v lab5a
</source>
:::4. Before proceeding, make certain that you identify any and all errors in lab5a.py. When the checking script tells you everything is OK before proceeding to the next step.
<br><br>

Navigation menu