IT 117: Introduction to Scripting
			Homework 3  
		
	
	
	Due
 Sunday, September 21st at 11:59 PM
	
	What You Need to Do
	
		- Create the script hw3.py
- Make sure it obeys the rules in
			Rules for Homework Scripts
		
- Make sure the script has a hashbang line and is executable
- Move it to an an hw3
			directory on pe15.cs.umb.edu  
		
Setup On Your Machine
	
		- Open a text editor.
 I would suggest the text editor built into the programIDLE.
- Save the file as hw3.py
- Copy the file full_student_data.txt from 
			/home/ghoffman/course_files/it117_files. 
 Use FileZilla to do this.
Specification
	
	Functions
	open_file_read
	
	student_dictionary_create
	
	   - Header 
def student_dictionary_create(file): 
- This function uses the file object 
        	file  to read in a file
        
- And use the data in the file to create a dictionary
- The keys are student IDs
- And the values are tuples holding
			
				- First name
- Last Name
- Username
- Email
 
- The function must return this dictionary
- Use the following algorithm
			
create an empty dictionary
for each line in the file
   run split()on the line to create the list fields
   the first entry in fields is the student ID, id
   collect the remaining entries into the tuple data
   create an entry in the dictionary with id key and data value
return the dictionary
 
student_dictionary_print
	
	
	Test Code
	
        - Your script must contain the following statements
- They should appear at the bottom of your script
filename = input("File name: ")
file = open_file_read(filename)
if file:
	students = student_dictionary_create(file)
	if students:
		student_dictionary_print(students)
	
		- This code will only work if you have copied
			full_student_data.txt into the same directory 
			as your script
		
- You will find this file in
			/home/ghoffman/course_files/it117_files
		
Output
	
	Suggestions
	
        - Write this script in stages
- Test your script at each step
- Print the steps below
- And check them off as you finish each one
		- 
			Create the file hw3.py.
 Enter the headers for open_file_read,
			student_dictionary_create and 
			student_dictionary_print.
 Under each header write the Python statementpass.
 Run the script.
 Fix any errors you find.
- 
			Replace the passstatement in 
			open_file_read with the body of the code from
			your hw2.py.
 Copy the test code into the bottom of the file.
 Comment out all but the first two lines.
 Run the scrip entering both a real filename and the name of a file
			that does not exists.
 Fix any errors you find.
- 
			Remove the passstatement in 
			student_dictionary_create.
 Replace it with aforloop on file using 
			line as the loop variable.
 Inside the loop, print line.
 Uncomment the next two lines in the test code..
 Run the script entering full_student_data.txt 
			when prompted.
 Fix any errors you find.
- 
			Remove the printstatement.
 Create the list variable fields by calling 
			the split method on 
			line.
 If you are not sure what I mean, see 
			Class Exercise 2.
 Print the value of fields.
 Run the script.
 Fix any errors you find.
- 
			Remove the printstatement.
 Create the variables id, 
			first, last,
			user and email 
			from fields using indexing.
 Again, see 
			Class Exercise 2
			for examples.
 Print these new variables.
 Run the script.
 Fix any errors you find.
- 
			Remove the printstatement.
 Create the tuple data containing
			the values of first, last,
			user and email.
 Print this tuple.
 Run the script.
 Fix any errors you find.
- 
			Remove the printstatement.
 Above theforloop, create the empty dictionary 
			students.
 As the last statement in theforloop, create an entry in
			students with id as the
			key and data as the value,
 Outside theforloop print 
			students.
 Run the script.
 Fix any errors you find.
- 
			Remove the printstatement.
 Replace it with areturnstatement 
			that returns students.
 In student_dictionary_print replace thepassstatement that prints the parameter 
			students.
 Uncomment the last two lines in the test code.
 Run the script.
 Fix any errors you find.
- 
			Remove the print statement. 
 Replace it with aforloop over 
			students using 
			id as the loop variable.
 The loop should be sorted by id.
 Inside theforloop print id.
 Run the script.
 Fix any errors you find.
- 
			Remove the printstatement.
 Create the tuple variable data
			from the value associated with id
			in the students dictionary.
 Create the variables first,
			last, user and
			email from data
			using indexing.
 Print id, first,
			last, user and
			email on a single line.
 Run the script.
 Fix any errors you find.
Testing on Your Machine
	
	
	Copy the Script to Unix
    
        - Open FileZilla and connect to
            pe15.cs.umb.edu
        
- Go to your it117 directory
- Go to your hw directory
- Right-click in the whitespace inside the 
              hw directory 
        
- Enter hw3 in the dialog box
-  Click and drag your script from the bottom left panel 
              to the bottom right panel
        
- Right-click on the file and select "Permissions" from 
            the menu
        
- Enter 755 in the box provided
- This will make the script executable
- Click and drag 
        	full_student_data.txt from the bottom left 
        	panel to the bottom right panel
        
Testing the Script on Unix (Optional)
    
	
	Copyright © 2020 Glenn Hoffman. All rights reserved. May not be reproduced without permission.