Friday, February 1, 2019

Display Values

  • Problem Description

    Write a program to display only the values of the keys in the output

    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 values of the concatenated dictionary

    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())
    d1.update({a:b})
    print("First Dictionary")
    print(d1)
    d2.update({c:d})
    print("Second Dictionary")
    print(d2)
    print("Concatenated dictionary is")
    d1.update(d2)
    print(d1)
    print("The Values of Dictionary")
    print([b,d])
  • Test Case 1

    Input (stdin)
    1
    
    111
    
    2
    
    222
    
    
    Expected Output
    First Dictionary
    
    {1: 111}
    
    Second Dictionary
    
    {2: 222}
    
    Concatenated dictionary is
    
    {1: 111, 2: 222}
    
    The Values of Dictionary
    
    [111, 222]
  • Test Case 2

    Input (stdin)
    3
    
    333
    
    4
    
    444
    
    
    Expected Output
    First Dictionary
    
    {3: 333}
    
    Second Dictionary
    
    {4: 444}
    
    Concatenated dictionary is
    
    {3: 333, 4: 444}
    
    The Values of Dictionary
    
    [333, 444]

No comments:

Post a Comment