Changes

Jump to: navigation, search

OPS435 Python Lab 4

4 bytes added, 23:45, 19 June 2017
PART 3 - String Formatting Expanded
'''Create a Script Demonstrating Formatting Strings'''
:'''Perform the Following Instructions:'''
:::#Create the '''~/ops435/lab4/lab4e.py''' script. The purpose of this script is to demonstrate formatting string output from a large data structure.:::#Use the following template to get started:<source>
#!/usr/bin/env python3
# Formatted Strings
:::*The values printed are center aligned by 20 characters
:::*The output must match the sample output EXACTLY if one character is off it will be wrong
::::'''Sample Run 1:'''<source>
run lab4e.py
|-------------Seneca College-------------|
|----------------------------------------|
</source>
::::'''Sample Run 2(with import):'''<source>
import lab4e
dict_york = {'Address': '70 The Pond Rd', 'City': 'Toronto', 'Country': 'Canada', 'Postal Code': 'M3J3M6', 'Province': 'ON'}
dict_newnham = {'Address': '1750 Finch Ave E', 'City': 'Toronto', 'Country': 'Canada', 'Postal Code': 'M2J2X5', 'Province': 'ON'}
college = 'Seneca College'
 
lab4e.print_college_address(dict_york, college)
|-------------Seneca College-------------|
| Country Canada |
|----------------------------------------|
 
lab4e.print_college_address(dict_newnham, college)
|-------------Seneca College-------------|
|----------------------------------------|
</source>
:::3. Exit the ipython3 shell, download the checking script and check your work. Enter the following commands from the bash shell.<source>
cd ~/ops435/lab4/
pwd #confirm that you are in the right directory
python3 ./CheckLab4.py -f -v lab4e
</source>
:::4. Before proceeding, make certain that you identify any and all errors in lab4e.py. When the checking script tells you everything is OK before proceeding to the next step.
<br><br>
198
edits

Navigation menu