Question-2: Write a Python program that takes a string as an input where multiple numbers are separated by hashes(#). Your first task is to create a list of numbers and print it. Your second task is to create a dictionary that will have the index of the list as key, and for the even indices, multiplication from start to that index as value, while for the odd indices, summation from start to that index as value. Finally, print the dictionary. . ================================================ Sample Input 1: 1#2#3#4 Sample Output 1: [1, 2, 3, 4] {0: 1, 1: 3, 2: 6, 3: 10} Explanation 1: key 0 → value 1 key 1 → value 1+2 = 3 key 2 → value 1x2x3 = 6 key 3 → value 1+2+3+4 = 10 ================================================ Sample Input 2: 5#6#7 Sample Output 2: [5, 6, 7] {0: 5, 1: 11, 2: 210} Explanation 2: key 0 → value 5 key 1 → value 5+6 = 11 key 2 → value 5x6x7 = 210.
Question-2: Write a Python program that takes a string as an input where multiple numbers are separated by hashes(#). Your first task is to create a list of numbers and print it.
Your second task is to create a dictionary that will have the index of the list as key, and for the even indices, multiplication from start to that index as value, while for the odd indices, summation from start to that index as value. Finally, print the dictionary.
. ================================================
Sample Input 1: 1#2#3#4
Sample Output 1: [1, 2, 3, 4] {0: 1, 1: 3, 2: 6, 3: 10}
Explanation 1:
key 0 → value 1 key 1 → value 1+2 = 3 key 2 → value 1x2x3 = 6 key 3 → value 1+2+3+4 = 10
================================================
Sample Input 2: 5#6#7 Sample Output 2: [5, 6, 7] {0: 5, 1: 11, 2: 210}
Explanation 2:
key 0 → value 5 key 1 → value 5+6 = 11 key 2 → value 5x6x7 = 210..
Step by step
Solved in 3 steps with 2 images