The university of new south wales COMP9021 QUIZ1 schoolwork parsing
Question:
Consolidate review python dictionary knowledge
Analytic:
Topic request have four points, 1 completion print statements, the number of elements in the statistical mapping dictionary, two statistical mapping in the dictionary, there is no key value, is stored in the nonkeys list, three statistical mapping the values of all the elements in the dictionary, is stored in the mapping_as_a_list list, 4 statistical mapping value only in the dictionary of elements, is stored in the one_to_one_part_of_mapping dictionaries,
Spilt () function for the user to enter two Numbers, press the space segmentation arg_for_seed and upper_bound respectively corresponding to the user to enter the first and second number + 1,
For I in range (1, upper_bound) said traversal cycle mapping dictionary elements (except for the first element) and assignment, each cycle call randrange () function to generate a random number within the prescribed scope, if this is what is a positive number is assigned to the corresponding dictionary elements, and the statistical number of dictionary elements available len (mapping), the second and third asked is to the operation of the dictionary elements, the fourth question is enumerated one-to-one mapping dictionary
Knowledge is involved:
Python dictionary, a list
PDF
Quizzes 1
COMP9021 all OF PROGRAMMING
$python3 quiz_1. Py
Enter two integers: 0 4
The generated mapping is:
{3:1}
The The mappings' s so - called "keys" make up a set whose number of elements is 1.
The list of integers between 1 and 4 that are not The keys of The mapping is:
[1, 2, 4]
Represented as a list, the mapping is:
[None, None, None, 1, None]
The one - to - one part of The mapping is:
{3:1}
$python3 quiz_1. Py
Enter two integers: 0 8
The generated mapping is:
{2, 4, 3, 8, 4, 7, 5, 7}
The The mappings' s so - called "keys" make up a set whose number of elements is 4.
The list of integers between 1 and 8 that are not The keys of The mapping is:
[1, 6, 7, 8]
Represented as a list, the mapping is:
[None, None, 4, 8, 7, 7, None, None, None]
The one - to - one part of The mapping is:
{2, 4, 3:8}
Date: Term 3, 2019.