Added work from my other class repositories before deletion

This commit is contained in:
2017-11-29 10:28:24 -08:00
parent cb0b5f4d25
commit 5ea24c81b5
198 changed files with 739603 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
# Assignment 5 - Python Exploration
# Corwin Perren
import os
import random
ASCII_MIN = ord('a')
ASCII_MAX = ord('z')
NUM_MIN = 1
NUM_MAX = 42
def make_file_with_random_letters(filename):
file = open(filename, "w")
for _ in range(10):
character_decimal = random.randint(ASCII_MIN, ASCII_MAX)
file.write(chr(character_decimal))
file.write('\n')
file.close()
def print_out_file(filename):
file = open(filename, "r")
lines = file.readlines()
for line in lines:
print "File \"" + filename + "\" contains: " + line,
file.close()
if __name__ == "__main__":
current_pid = os.getpid()
filenames = [
str(current_pid) + "_1.txt",
str(current_pid) + "_2.txt",
str(current_pid) + "_3.txt"
]
print "Generating files with names:"
for name in filenames:
make_file_with_random_letters(name)
print name
print "\nContents of files are:"
for name in filenames:
print_out_file(name)
print "\nGenerating two random numbers:"
first_number = random.randint(NUM_MIN, NUM_MAX)
second_number = random.randint(NUM_MIN, NUM_MAX)
print "First number is: " + str(first_number)
print "Second number is: " + str(second_number)
print "Product of the two numbers is: " + str(first_number*second_number)