Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

7/11/22, 11:28 AM sowmya case study.

pdf - Colaboratory

##### ASSEMBLER.
xe = input()
j = 0
for j in range(0, (len(xe))):
    if xe[j] == 'a':
        print('01000001', end=' ')
    if xe[j] == 'b':
        print('01000010', end=' ')
    if xe[j] == 'c':
        print('01000011', end=' ')
    if xe[j] == 'd':
        print('01000100', end=' ')
    if xe[j] == 'e':
        print('01000101', end=' ')
  if xe[j] == 'f':
        print('01000110', end=' ')
    if xe[j] == 'g':
        print('01000111', end=' ')
    if xe[j] == 'h':
        print('01001000', end=' ')
    if xe[j] == 'i':
        print('01001001', end=' ')
    if xe[j] == 'j':
        print('01001010', end=' ')
    if xe[j] == 'k':
        print('01001011', end=' ')
    if xe[j] == 'l':
        print('01001100', end=' ')
    if xe[j] == 'm':
        print('01001101', end=' ')
    if xe[j] == 'n':
        print('01001110', end=' ')
    if xe[j] == 'o':
        print('01001111', end=' ')
    if xe[j] == 'p':
        print('01010000', end=' ')
    if xe[j] == 'q':
        print('01010001', end=' ')
    if xe[j] == 'r':
        print('01010010', end=' ')
    if xe[j] == 's':
        print('01010011', end=' ')
    if xe[j] == 't':
        print('01010100', end=' ')
    if xe[j] == 'u':
        print('01010101', end=' ')
    if xe[j] == 'v':
        print('01010110', end=' ')
    if xe[j] == 'w':
        print('01010111', end=' ')
    if xe[j] == 'x':
        print('01011000', end=' ')
    if xe[j] == 'y':
print('01011001', end=' ')
https://colab.research.google.com/drive/1EYGKxgtKONiH3yxS3rQPb2H3RAl64-QW#scrollTo=U-FUfFF0zead&printMode=true 1/6
7/11/22, 11:28 AM sowmya case study.pdf - Colaboratory
        print( 01011001 , end   )
    if xe[j] == 'z':
        print('01011010', end=' ')
    if xe[j] == 'A':
        print('01000001', end=' ')
    if xe[j] == 'B':
        print('01000010', end=' ')
    if xe[j] == 'C':
        print('01000011', end=' ')
    if xe[j] == 'D':
        print('01000100', end=' ')
    if xe[j] == 'E':
        print('01000101', end=' ')
    if xe[j] == 'F':
        print('01000110', end=' ')
    if xe[j] == 'G':
        print('01000111', end=' ')
    if xe[j] == 'H':
        print('01001000', end=' ')
    if xe[j] == 'I':
        print('01001001', end=' ')
    if xe[j] == 'J':
        print('01001010', end=' ')
    if xe[j] == 'K':
        print('01001011', end=' ')
    if xe[j] == 'L':
        print('01001100', end=' ')
    if xe[j] == 'M':
        print('01001101', end=' ')
    if xe[j] == 'N':
        print('01001110', end=' ')
    if xe[j] == 'O':
        print('01001111', end=' ')
    if xe[j] == 'P':
        print('01010000', end=' ')
    if xe[j] == 'Q':
        print('01010001', end=' ')
    if xe[j] == 'R':
        print('01010010', end=' ')
    if xe[j] == 'S':
        print('01010011', end=' ')
    if xe[j] == 'T':
        print('01010100', end=' ')
    if xe[j] == 'U':
        print('01010101', end=' ')
    if xe[j] == 'V':
        print('01010110', end=' ')
    if xe[j] == 'W':
        print('01010111', end=' ')
    if xe[j] == 'X':
        print('01011000', end=' ')
    if xe[j] == 'Y':
        print('01011001', end=' ')
    if xe[j] == 'Z':
        print('01011010', end=' ')

https://colab.research.google.com/drive/1EYGKxgtKONiH3yxS3rQPb2H3RAl64-QW#scrollTo=U-FUfFF0zead&printMode=true 2/6
7/11/22, 11:28 AM sowmya case study.pdf - Colaboratory

#####MILESTONE 1

from common_elements import common

def main():

print("common(['a'], ['a']) returns: ")

print(common(['a'], ['a'])) # should print ['a']

print("common(['a', 'b', 'c'], ['x', 'a', 'z', 'c']) returns:")

print(common(['a', 'b', 'c'], ['x', 'a', 'z', 'c'])) # should print ['a', 'c']

print("common(['a', 'b', 'c'], ['x', 'y', 'z']) returns:")

print(common(['a', 'b', 'c'], ['x', 'y', 'z'])) # should print []

print("common(['a', 'b', 'c'], ['a', 'a', 'x']) returns:")

print(common(['a', 'a', 'b'], ['a', 'a', 'x'])) # should print ['a']

if __name__ == '__main__':

main()

##DERIVATION

from derive_equation import derive_equation

derivation_num = 3

eq_string = "12x^4+2x^3+6x^2+x^1+1"

print(derive_equation(derivation_num, eq_string))

######MILESTONE2

from searchengine import textfiles_in_dir, create_index

import os

import sys

import string

def main():

    """

    Usage: searchengine.py <file directory> -s

    The first argument specified should be the directory of text files that

    will be indexed/searched.  If the parameter -s is provided, then the

    user can interactively search (using the index).  Otherwise (if -s is

    not included), the index and the dictionary mapping file names to article

    titles are just printed on the console.

    """

    # Get command line arguments

    args = sys.argv[1:]

    num_args = len(args)

    if num_args < 1:

        print('Please specify directory of files to index as first argument.')

    else:

        # args[0] should be the folder containing all the files to index/search.

        directory = args[0]

        if os.path.exists(directory):

            # Build index from files in the given directory

            files = textfiles_in_dir(directory)

            index = {}          # index is empty to start

            file_titles = {}    # mapping of file names to article titles is empty to star
            create_index(files, index, file_titles)

            print('Index:')

            print(index)

https://colab.research.google.com/drive/1EYGKxgtKONiH3yxS3rQPb2H3RAl64-QW#scrollTo=U-FUfFF0zead&printMode=true 3/6
7/11/22, 11:28 AM sowmya case study.pdf - Colaboratory

            print('File names -> document titles:')

            print(file_titles)

        else:

            print('Directory "' + directory + '" does not exist.')

if __name__ == '__main__':

    main()

###MILE STONE 3

import os

import sys

import string

from searchengine_advanced import create_index, do_searches, search, textfiles_in_dir

def main():

    """

    Usage: searchengine.py <file directory> -s

    The first argument specified should be the directory of text files that

    will be indexed/searched.  If the parameter -s is provided, then the

    user can interactively search (using the index).  Otherwise (if -s is

    not included), the index and the dictionary mapping file names to article

    titles are just printed on the console.

    """

    # Get command line arguments

    args = sys.argv[1:]

    num_args = len(args)

    if num_args < 1 or num_args > 2:

        print('Please specify directory of files to index as first argument.')

        print('Add -s to also search (otherwise, index and file titles will just be printe
    else:

        # args[0] should be the folder containing all the files to index/search.

        directory = args[0]

        if os.path.exists(directory):

            # Build index from files in the given directory

            files = textfiles_in_dir(directory)

            index = {}          # index is empty to start

            file_titles = {}    # mapping of file names to article titles is empty to star
            create_index(files, index, file_titles)

            # Either allow the user to search using the index, or just print the index

            if num_args == 2 and args[1] == '-s':

                do_searches(index, file_titles)

            else:

                print('Index:')

                print(index)

                print('File names -> document titles:')

                print(file_titles)

        else:

            print('Directory "' + directory + '" does not exist.')

if __name__ == '__main__':

    main()

https://colab.research.google.com/drive/1EYGKxgtKONiH3yxS3rQPb2H3RAl64-QW#scrollTo=U-FUfFF0zead&printMode=true 4/6
7/11/22, 11:28 AM sowmya case study.pdf - Colaboratory

### Milestone-2
from searchengine import textfiles_in_dir, create_index
import os
import sys
import string
def main():
"""
Usage: searchengine.py <file directory> -s
The first argument specified should be the directory of text files that

will be indexed/searched. If the parameter -s is provided, then the
user can interactively search (using the index). Otherwise (if -s is
not included), the index and the dictionary mapping file names to article
titles are just printed on the console.
"""
# Get command line arguments
args = sys.argv[1:]
num_args = len(args)
if num_args < 1:
print('Please specify directory of files to index as first argument.')
else:
# args[0] should be the folder containing all the files to index/search.
directory = args[0]
if os.path.exists(directory):
# Build index from files in the given directory
files = textfiles_in_dir(directory)
index = {} # index is empty to start
file_titles = {} # mapping of file names to article titles is empty to start
create_index(files, index, file_titles)
print('Index:')
print(index)
print('File names -> document titles:')
print(file_titles)
else:
print('Directory "' + directory + '" does not exist.')
if __name__ == '__main__':
main()

https://colab.research.google.com/drive/1EYGKxgtKONiH3yxS3rQPb2H3RAl64-QW#scrollTo=U-FUfFF0zead&printMode=true 5/6
7/11/22, 11:28 AM sowmya case study.pdf - Colaboratory

https://colab.research.google.com/drive/1EYGKxgtKONiH3yxS3rQPb2H3RAl64-QW#scrollTo=U-FUfFF0zead&printMode=true 6/6

You might also like