Wednesday, December 16, 2020

python day11 dictionaries

 '''day11


concept : dictionary


#empty dictionary

d1={}

print(type(d1))


d1={

        "key":1,

        "key2":2

    }

print(d1)


d1={

        "key":1,

        "key2":2

    }

print(d1["key"])



d1={

        "key":1,

        "key2":2

    }

print(d1["key"],d1["key2"])


d1={

        "key":1,

        "key2":2

    }

print(d1["key"])



d2={

    "flowers":"rose","flowers1":"rose","flowers2":"rose","flowers3":"rose","flowers4":"rose",

    

    }


print(d2["flowers"])

print(d2["flowers1"])

print(d2["flowers2"])

print(d2["flowers4"])

print(d2["flowers3"])



d2={

    "flowers":"rose","flowers":"rose","flowers":"rose","flowers":"rose","flowers":"rose",

    

    }


print(d2["flowers"])

print(d2["flowers"])

print(d2["flowers"])

print(d2["flowers"])

print(d2["flowers"])



d2={

    "flowers":"rose",

    "flowers":"jasmin",

    "flowers":"lilli",

    "flowers":"chilli",

    "flowers":"lolli",

    

    }


print(d2["flowers"])

print(d2["flowers"])

print(d2["flowers"])

print(d2["flowers"])

print(d2["flowers"])




#nested dictionary

d2={

    "flowers":{"fl":"chamanthi"},

    "flowers1":"jasmin",

    "flowers2":"lilli",

    "flowers3":"chilli",

    "flowers4":"lolli",

    

    }


print(d2["flowers"]["fl"])

print(d2["flowers1"])

print(d2["flowers2"])

print(d2["flowers3"])

print(d2["flowers4"])



#nested dictionary

d2={

    "flowers":{"fl":"chamanthi"},

    "flowers1":{"fl":"chamanthi"},

    "flowers2":{"fl":"chamanthi"},

    "flowers3":{"fl":"chamanthi"},

    "flowers4":{"fl":"chamanthi"},

    

    }


print(d2["flowers"]["fl"])

print(d2["flowers1"]["fl"])

print(d2["flowers2"]["fl"])

print(d2["flowers3"]["fl"])

print(d2["flowers4"]["fl"])



d2={

    "flowers":{"fl":"chamanthi"},

    "flowers1":{"fl":"chamanthi1"},

    "flowers2":{"fl":"chamanthi2"},

    "flowers3":{"fl":"chamanthi3"},

    "flowers4":{"fl":"chamanthi4"},

    

    }


print(d2["flowers"]["fl"])

print(d2["flowers1"]["fl"])

print(d2["flowers2"]["fl"])

print(d2["flowers3"]["fl"])

print(d2["flowers4"]["fl"])



d2={

    "flowers":{"fl":{"st1":"praveen"}},

    "flowers1":{"fl":"chamanthi1"},

    "flowers2":{"fl":"chamanthi2"},

    "flowers3":{"fl":"chamanthi3"},

    "flowers4":{"fl":"chamanthi4"},

    

    }


print(d2["flowers"]["fl"]["st1"])

print(d2["flowers1"]["fl"])

print(d2["flowers2"]["fl"])

print(d2["flowers3"]["fl"])

print(d2["flowers4"]["fl"])



#list in dictionary

d2={

    "flowers":[1,2,3],

    "flowers1":{"fl":"chamanthi1"},

    "flowers2":{"fl":"chamanthi2"},

    "flowers3":{"fl":"chamanthi3"},

    "flowers4":{"fl":"chamanthi4"},

    

    }


print(d2["flowers"])

print(type(d2))

print(type(d2["flowers"]))

'''

#tuple in dictionary

d2={

    "flowers":{"key3":3},

    "flowers1":{"fl":"chamanthi1"},

       

    }


print(d2["flowers"])

print(type(d2))

print(type(d2["flowers"]))





















python class topic video