0% found this document useful (0 votes)
188 views2 pages

Python3 Quiz - 2.py 0 4

This document contains the output of running a Python program called quiz_2.py multiple times with different integer inputs. For each run, it generates a mapping of keys to values, lists the keys in order, finds the cycles in the mapping, and creates a reversed dictionary grouped by cycle length. It provides examples with inputs ranging from 0 to 50 that demonstrate the different outputs.

Uploaded by

Junliang Liao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
188 views2 pages

Python3 Quiz - 2.py 0 4

This document contains the output of running a Python program called quiz_2.py multiple times with different integer inputs. For each run, it generates a mapping of keys to values, lists the keys in order, finds the cycles in the mapping, and creates a reversed dictionary grouped by cycle length. It provides examples with inputs ranging from 0 to 50 that demonstrate the different outputs.

Uploaded by

Junliang Liao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

QUIZ 2

COMP9021 PRINCIPLES OF PROGRAMMING

$ python3 quiz_2.py
Enter two integers: 0 4

The generated mapping is:


{2: 3, 4: 1}

The keys are, from smallest to largest:


[2, 4]

Properly ordered, the cycles given by the mapping are:


[]

The (triply ordered) reversed dictionary per lengths is:


{1: {1: [4], 3: [2]}}
$ python3 quiz_2.py
Enter two integers: 0 6

The generated mapping is:


{1: 1, 3: 3, 5: 6, 6: 6}

The keys are, from smallest to largest:


[1, 3, 5, 6]

Properly ordered, the cycles given by the mapping are:


[[1], [3], [6]]

The (triply ordered) reversed dictionary per lengths is:


{1: {1: [1], 3: [3]}, 2: {6: [5, 6]}}
$ python3 quiz_2.py
Enter two integers: 0 11

The generated mapping is:


{2: 7, 3: 11, 4: 10, 5: 10, 7: 2, 9: 5, 10: 10, 11: 5}

The keys are, from smallest to largest:


[2, 3, 4, 5, 7, 9, 10, 11]

Properly ordered, the cycles given by the mapping are:


[[2, 7], [10]]

The (triply ordered) reversed dictionary per lengths is:


{1: {2: [7], 7: [2], 11: [3]}, 2: {5: [9, 11]}, 3: {10: [4, 5, 10]}}

Date: Trimester 2, 2019.


2 COMP9021 PRINCIPLES OF PROGRAMMING

$ python3 quiz_2.py
Enter two integers: 10 9

The generated mapping is:


{1: 5, 2: 6, 3: 5, 4: 5, 5: 6, 6: 7, 7: 1, 9: 6}

The keys are, from smallest to largest:


[1, 2, 3, 4, 5, 6, 7, 9]

Properly ordered, the cycles given by the mapping are:


[[1, 5, 6, 7]]

The (triply ordered) reversed dictionary per lengths is:


{1: {1: [7], 7: [6]}, 3: {5: [1, 3, 4], 6: [2, 5, 9]}}
$ python3 quiz_2.py
Enter two integers: 20 11

The generated mapping is:


{2: 4, 3: 9, 4: 4, 5: 8, 6: 2, 7: 5, 8: 11, 9: 1, 10: 10, 11: 5}

The keys are, from smallest to largest:


[2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

Properly ordered, the cycles given by the mapping are:


[[4], [5, 8, 11], [10]]

The (triply ordered) reversed dictionary per lengths is:


{1: {1: [9], 2: [6], 8: [5], 9: [3], 10: [10], 11: [8]},
2: {4: [2, 4], 5: [7, 11]}}
$ python3 quiz_2.py
Enter two integers: 50 15

The generated mapping is:


{1: 5, 2: 14, 3: 15, 4: 3, 5: 5, 6: 5, 7: 15, 8: 6, 9: 10, 10: 15, 11: 12,
12: 15, 13: 14, 14: 8, 15: 9}

The keys are, from smallest to largest:


[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]

Properly ordered, the cycles given by the mapping are:


[[5], [9, 10, 15]]

The (triply ordered) reversed dictionary per lengths is:


{1: {3: [4], 6: [8], 8: [14], 9: [15], 10: [9], 12: [11]},
2: {14: [2, 13]},
3: {5: [1, 5, 6]},
4: {15: [3, 7, 10, 12]}}

You might also like