0% found this document useful (0 votes)
8 views

Programming Assignment Unit 8 (1)

The document is a programming assignment by Zin Myo Tun from the University of the People, detailing the process of reading a text file, parsing its content into a dictionary, and inverting that dictionary. It includes the output of the original and inverted dictionaries, showcasing the transformation of data. The assignment is supervised by Dr. Vikas Thada and is dated January 12, 2024.

Uploaded by

Zin Myo
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Programming Assignment Unit 8 (1)

The document is a programming assignment by Zin Myo Tun from the University of the People, detailing the process of reading a text file, parsing its content into a dictionary, and inverting that dictionary. It includes the output of the original and inverted dictionaries, showcasing the transformation of data. The assignment is supervised by Dr. Vikas Thada and is dated January 12, 2024.

Uploaded by

Zin Myo
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

1|Page

Programming Assignment Unit 7

By

Zin Myo Tun


Department of Computer Science, University of the People
CS-1101-01: Programming Fundamentals - AY2024-T2

Supervised By

Dr Vikas Thada
Instructor, Department of Computer Science
University of the People

January 12, 2024

Zin Myo Tun, C1839791


2|Page

Explanation
I decided to first open the
text file in reading mode
and read the content and
parse every line in the
content into a dictionary.
Using for loop to the
dictionary strings to write
the file and added three
other
items, then read and stored
the items of the inverted
dictionary to the file
Explanation
I decided to first open the
text file in reading mode
Zin Myo Tun, C1839791
3|Page

and read the content and


parse every line in the
content into a dictionary.
Using for loop to the
dictionary strings to write
the file and added three
other
items, then read and stored
the items of the inverted
dictionary to the file
Explanation
I decided to first open the
text file in reading mode
and read the content and
parse every line in the

Zin Myo Tun, C1839791


4|Page

content into a dictionary.


Using for loop to the
dictionary strings to write
the file and added three
other
items, then read and stored
the items of the inverted
dictionary to the file
Explanation
I decided to first open the
text file in reading mode
and read the content and
parse every line in the
content into a dictionary.
Using for loop to the
dictionary strings to write
Zin Myo Tun, C1839791
5|Page

the file and added three


other
items, then read and stored
the items of the inverted
dictionary to the file
Explanation
I decided to first open the text file in reading mode and read the content and parse every line in
the content into a dictionary. Using for loop to the dictionary strings to write the file and added
three other items, then read and stored the items of the inverted dictionary to the file.

Zin Myo Tun, C1839791


6|Page

Output
The list from the text file
BEFORE inverting:
{'Alex': ['dog', 9, 'male'],
'Beth': ['rabbit', 15, 'female'],
'Christine':
['rabbit', 15, 'female'],
'Dennis': ['cat', 19, 'male'],
'Earnest': ['dog', 10,

Zin Myo Tun, C1839791


7|Page

'male'], 'Eve': ['cat ', 9,


'female'], 'Florence': ['rabbit',
19, 'female'],
'Ian': ['rabbit', 10, 'male'],
'Peter': ['dog', 10, 'male'],
'Simon': ['cat', 9,
'male'], 'Aurthur': ['Cat', 15,
'male'], 'Sara': ['rabbit', 19,
'female'],
'Maria': ['dog', 10, 'female']}
The list from the text file
AFTER inverting:
{'dog': ['Alex', 'Earnest',
'Peter', 'Maria'], 9: ['Alex',
'Eve', 'Simon'],

Zin Myo Tun, C1839791


8|Page

'male': ['Alex', 'Dennis',


'Earnest', 'Ian', 'Peter',
'Simon', 'Aurthur'],
'rabbit': ['Beth', 'Christine',
'Florence', 'Ian', 'Sara'], 15:
['Beth',
'Christine', 'Aurthur'],
'female': ['Beth', 'Christine',
'Eve', 'Florence',
Output
The list from the text file
BEFORE inverting:
{'Alex': ['dog', 9, 'male'],
'Beth': ['rabbit', 15, 'female'],
'Christine':

Zin Myo Tun, C1839791


9|Page

['rabbit', 15, 'female'],


'Dennis': ['cat', 19, 'male'],
'Earnest': ['dog', 10,
'male'], 'Eve': ['cat ', 9,
'female'], 'Florence': ['rabbit',
19, 'female'],
'Ian': ['rabbit', 10, 'male'],
'Peter': ['dog', 10, 'male'],
'Simon': ['cat', 9,
'male'], 'Aurthur': ['Cat', 15,
'male'], 'Sara': ['rabbit', 19,
'female'],
'Maria': ['dog', 10, 'female']}
The list from the text file
AFTER inverting:

Zin Myo Tun, C1839791


10 | P a g e

{'dog': ['Alex', 'Earnest',


'Peter', 'Maria'], 9: ['Alex',
'Eve', 'Simon'],
'male': ['Alex', 'Dennis',
'Earnest', 'Ian', 'Peter',
'Simon', 'Aurthur'],
'rabbit': ['Beth', 'Christine',
'Florence', 'Ian', 'Sara'], 15:
['Beth',
'Christine', 'Aurthur'],
'female': ['Beth', 'Christine',
'Eve', 'Florence',
Output
The list from the text file
BEFORE inverting:

Zin Myo Tun, C1839791


11 | P a g e

{'Alex': ['dog', 9, 'male'],


'Beth': ['rabbit', 15, 'female'],
'Christine':
['rabbit', 15, 'female'],
'Dennis': ['cat', 19, 'male'],
'Earnest': ['dog', 10,
'male'], 'Eve': ['cat ', 9,
'female'], 'Florence': ['rabbit',
19, 'female'],
'Ian': ['rabbit', 10, 'male'],
'Peter': ['dog', 10, 'male'],
'Simon': ['cat', 9,
'male'], 'Aurthur': ['Cat', 15,
'male'], 'Sara': ['rabbit', 19,
'female'],
'Maria': ['dog', 10, 'female']}

Zin Myo Tun, C1839791


12 | P a g e

The list from the text file


AFTER inverting:
{'dog': ['Alex', 'Earnest',
'Peter', 'Maria'], 9: ['Alex',
'Eve', 'Simon'],
'male': ['Alex', 'Dennis',
'Earnest', 'Ian', 'Peter',
'Simon', 'Aurthur'],
'rabbit': ['Beth', 'Christine',
'Florence', 'Ian', 'Sara'], 15:
['Beth',
'Christine', 'Aurthur'],
'female': ['Beth', 'Christine',
'Eve', 'Florence',
Output
The list from the text file BEFORE inverting:
{'Alex': ['dog', 9, 'male'], 'Beth': ['rabbit', 15, 'female'], 'Christine': ['rabbit', 15, 'female'], 'Dennis':
['cat', 19, 'male'], 'Earnest': ['dog', 10, 'male'], 'Eve': ['cat ', 9, 'female'], 'Florence': ['rabbit', 19,
'female'], 'Ian': ['rabbit', 10, 'male'], 'Peter': ['dog', 10, 'male'], 'Simon': ['cat', 9, 'male'], 'Aurthur':
['Cat', 15, 'male'], 'Sara': ['rabbit', 19, 'female'], 'Maria': ['dog', 10, 'female']}
The list from the text file AFTER inverting:

Zin Myo Tun, C1839791


13 | P a g e

{'dog': ['Alex', 'Earnest', 'Peter', 'Maria'], 9: ['Alex', 'Eve', 'Simon'], 'male': ['Alex', 'Dennis',
'Earnest', 'Ian', 'Peter', 'Simon', 'Aurthur'], 'rabbit': ['Beth', 'Christine', 'Florence', 'Ian', 'Sara'], 15:
['Beth', 'Christine', 'Aurthur'], 'female': ['Beth', 'Christine', 'Eve', 'Florence', 'Sara', 'Maria'], 'cat':
['Dennis', 'Simon'], 19: ['Dennis', 'Florence', 'Sara'], 10: ['Earnest', 'Ian', 'Peter', 'Maria'], 'cat ':
['Eve'], 'Cat': ['Aurthur']}

xplanation
I decided to first open the
text file in reading mode
and read the content and
parse every line in the
content into a dictionary.
Using for loop to the
dictionary strings to write
the file and added three
other
items, then read and stored
the items of the inverted
dictionary to the file
xplanation
Zin Myo Tun, C1839791
14 | P a g e

I decided to first open the


text file in reading mode
and read the content and
parse every line in the
content into a dictionary.
Using for loop to the
dictionary strings to write
the file and added three
other
items, then read and stored
the items of the inverted
dictionary to the file
xplanation
I decided to first open the
text file in reading mode

Zin Myo Tun, C1839791


15 | P a g e

and read the content and


parse every line in the
content into a dictionary.
Using for loop to the
dictionary strings to write
the file and added three
other
items, then read and stored
the items of the inverted
dictionary to the file
xplanation
I decided to first open the
text file in reading mode
and read the content and
parse every line in the

Zin Myo Tun, C1839791


16 | P a g e

content into a dictionary.


Using for loop to the
dictionary strings to write
the file and added three
other
items, then read and stored
the items of the inverted
dictionary to the file
xplanation
I decided to first open the
text file in reading mode
and read the content and
parse every line in the
content into a dictionary.
Using for loop to the
dictionary strings to write
Zin Myo Tun, C1839791
17 | P a g e

the file and added three


other
items, then read and stored
the items of the inverted
dictionary to the file
xplanation
I decided to first open the
text file in reading mode
and read the content and
parse every line in the
content into a dictionary.
Using for loop to the
dictionary strings to write
the file and added three
other

Zin Myo Tun, C1839791


18 | P a g e

items, then read and stored


the items of the inverted
dictionary to the file
xplanation
I decided to first open the
text file in reading mode
and read the content and
parse every line in the
content into a dictionary.
Using for loop to the
dictionary strings to write
the file and added three
other
items, then read and stored
the items of the inverted
dictionary to the file
Zin Myo Tun, C1839791
19 | P a g e

xplanation
I decided to first open the
text file in reading mode
and read the content and
parse every line in the
content into a dictionary.
Using for loop to the
dictionary strings to write
the file and added three
other
items, then read and stored
the items of the inverted
dictionary to the file

Zin Myo Tun, C1839791

You might also like