Python Dictionary Board Questions


  1. Write a Python statement for each of the following tasks using built-in functions/methods only : To remove the item whose key is "NISHA" from a dictionary named Students. [1 MARK] [2024]

    For example
    if the dictionary Students contains {"ANITA":90, "NISHA":76, "ASHA":92} ,

    then after removal the dictionary should contain {"ANITA":90, "ASHA":92}
  2. Students.pop("NISHA")
     
    OR
    
    del (Students["NISHA"])
    
    OR
    
    del Students["NISHA"]
    
    OR
     
    Any other correct variation of the code
    

  3. Write the output displayed on execution of the following Python code : [2 MARKS] [2024]

    LS=["HIMALAYA", "NILGIRI", "ALASKA", "ALPS"]
    D={}
    for S in LS :
        if len(S) % 4 == 0 :
            D[S] = len(S)
    for K in D :
        print(K, D[K], sep="#")
    
  4. HIMALAYA#8
    ALPS#4
    

  5. Which of the following statement(s) would give an error after executing the following code ? [1 MARK] [2023]

    Stud= { "Murugan":100, "Mithu":95 }     #Statement 1
    print(Stud[95])                         #Statement 2
    Stud [ "Murugan" ]= 99                  #Statement 3
    print(Stud.pop( ))                      #Statement 4
    print(Stud)                             #Statement 5
    
    (a) Statement 2		
    (b) Statement 3		
    (c) Statement 4		
    (d) Statement 2 and 4
    
  6. (a) Statement 2 
    OR
    (d) Statements 2 and 4