Friday, February 1, 2019

Multiple

  • Problem Description

    Write a program to add multiply dictionaries

    Input:

    1.Get two dictionaries key-value elements

    Output:
    1. Display the first dictionary
    2. Display the second dictionary
    3. Display the concatenated dictionary
    4. Display the total product of the values in the dictionaries

    Refer sample input and output for formatting specification. 

    All float values are displayed correct to 2 decimal places. 

    All text in bold corresponds to input and the rest corresponds to output
  • CODING ARENA
  • d1={}
    d2={}
    a=int(input())
    b=int(input())
    c=int(input())
    d=int(input())
    print("First Dictionary")
    d1.update({a:b})
    d2.update({c:d})
    print(d1)
    print("Second Dictionary")
    print(d2)
    print("Concatenated dictionary is")
    d1.update(d2)
    print(d1)
    print("Total sum of values in the dictionary")
    print(b*d)
  • Test Case 1

    Input (stdin)
    10
    
    35
    
    12
    
    36
    
    
    Expected Output
    First Dictionary
    
    {10: 35}
    
    Second Dictionary
    
    {12: 36}
    
    Concatenated dictionary is
    
    {10: 35, 12: 36}
    
    Total sum of values in the dictionary
    
    1260
  • Test Case 2

    Input (stdin)
    6
    
    16
    
    8
    
    18
    
    
    Expected Output
    First Dictionary
    
    {6: 16}
    
    Second Dictionary
    
    {8: 18}
    
    Concatenated dictionary is
    
    {6: 16, 8: 18}
    
    Total sum of values in the dictionary
    
    288

No comments:

Post a Comment