ICS4

Module 4 (April 24 - May 13)

This Module will offer an introduction to encryption and file Input/Output.

Python Style

  • If you want to learn more about standard style conventions in Python, refer to the Python Style Guide. It's a good reference if you're looking for explicit style recommendations. You may like to review the section on comments.

Encryption

Can you explain how the secret message, "Hello my name is Simon", was encrypted in each of the following?

  1. "Ellohay my amenay is imonsay"
  2. "Ifmmp nz obnf jt tjnpo"
  3. "Jraap zu mszr od dozpm"

Some recommended resources about encryption

  • Caesar Cipher decryption tool
  • Here's an interesting Khanacademy series about cryptography
  • Simon Singh's The Code Book, about the history of encryption and the secrets of codebreaking, is an excellent read
  • EFF, is a foundation dedicated to defending digital privacy rights. Check out their website and join their mailing list to stay informed about the ever-changing landscape of online privacy

File IO Basics/b>

 
	"""
	For a summary of file input/output in Python:
	https://www.tutorialspoint.com/python/python_files_io.htm
	Pay attention to placement of file pointer for various access modes

	"""

	filename = input("name your doc for your marks") #will create file if it doesn't already exist
	numEntries = int(input("how many marks you got?"))
	f=open(filename+".txt",'w')  #'a' will append instead of overwrite

	for mark in range(numEntries):
    	    f.write(input("Enter your marks: ")+"\n")
	f.close()
    

Here's a Codecademy tutorial about File I/O for reference


Review for Quiz

  • File IO in Python (open, close, read, write). See highlights on Ref Sheet
  • Codecademy tutorial for file I/O
  • Test cases from Module 3. See "AllFlufffy" and "isTeenager" examples.
  • Something to think about: How will the output differ for the following two code fragments?
  
	for line in f: 
	    print(line) 

	for line in f: 
	    print(line) 
	    f.readline() 
    

Quiz Part 1 (Testing): May 7 2019
Quiz Part 2 (File I/O): May 14 2019

Post Your File IO Top 10 Scores Exercise here. It's a public repo