Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve using python3 Question-2: Write a Python program that will take your Student ID as an input and print a dictionary, where the keys will

solve using python3image text in transcribed

Question-2: Write a Python program that will take your Student ID as an input and print a dictionary, where the keys will be the unique digits from your given Student ID and the value will be a list of tuples according to the following. Here, every tuple will hold two indices, where the first index will hold the index of that digit's Nth occurrence in the given Student ID and the second index will hold the number of occurrences thus far or the Nth value. Sample Input 1: 17301106 Sample Output 1: {1: [(0,1),(4,2), (5, 3)], 7: [(1, 1)), 3: [(2, 1)), O: [(3, 1), (6, 2)], 6: [(7, 1))} Explanation 1: Here, in the given Student ID, unique digits are: 1,7, 3,0 and 6. So, the keys will be 1, 7, 3, 0 and 6. Moving forward, in the given Student ID, 1 is in 0, 4 and 5 indices, therefore for the three occurrences, there will be a list of three tuples as a value for the key 1. So, the value will be [(Index: 0, Occurrence: 1), (Index: 4, Occurrence: 2), (Index: 5, Occurrence: 3)] and so on similarly for the keys 7, 3, 0 and 6. Sample Input 2: 21166055 Sample Output 2: {2: [(0, 1)], 1: [(1, 1), (2, 2)], 6: [(3, 1), (4, 2)], 0: [(5, 1)], 5: [(6, 1), (7, 2)]} Explanation 2: Here, in the given Student ID, unique digits are: 2, 1, 6,0 and 5. So, the keys will be 2, 1,6, 0 and 5. Furthermore, in the given Student ID, 2 has occurred in only index 0, therefore for the only occurrence, there will be a list of one tuple as a value for the key 2. So, the value will be [(Index: 0, Occurrence: 1)] and so on and so forth for the rest of the unique digit keys

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions