Program:
print("\n< G\tO\tO\tG\tL\tE />")google={"Company":"Google Inc. (1998–2019)",
"Founded":"September 4, 1998",
"Founders":"Larry Page & Sergey Brin",
"Headquarters":"California, U.S.A.",
"CEO":"Sundar Pichai",
"Website":"google.com"}
print("\nAll keys:\n\t >",google.keys())
print("\nAll values:\n\t >",google.values())
print("\nAll Items:",google.items())
s1=str(input("\nEnter key:"))
print("\t>",google.get(s1))
s2=str(input("Removes the element with the specified key:"))
if(s2 in google):
google.pop(s2)
print(s2+" Successfully Removed.")
print("\nNOW All keys:\n\t >",google.keys())
else:
print(" Keys NOT FOUND!")
Expected O/P:
< G O O G L E />
All keys:
> dict_keys(['Company', 'Founded', 'Founders', 'Headquarters', 'CEO', 'Website'])
All values:
> dict_values(['Google Inc. (1998–2019)', 'September 4, 1998', 'Larry Page & Sergey Brin', 'California, U.S.A.', 'Sundar Pichai', 'google.com'])
All Items: dict_items([('Company', 'Google Inc. (1998–2019)'), ('Founded', 'September 4, 1998'), ('Founders', 'Larry Page & Sergey Brin'), ('Headquarters', 'California, U.S.A.'), ('CEO', 'Sundar Pichai'), ('Website', 'google.com')])
Enter key:CEO
> Sundar Pichai
Removes the element with the specified key:Founders
Founders Successfully Removed.
NOW All keys:

0 Comments
Post a Comment