Wednesday, April 29, 2020

Remove a key from a Dictionary in Python


Write a Python program to remove a key from a dictionary.


I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.unlimitedbooksph.com/

Program Listing



print()
print("\tRemove a key from a dictionary");
print()
myDictionary = {'a':1,'b':2,'c':3,'d':4}
print("\t",myDictionary)
if 'a' in myDictionary:
    del myDictionary['a']
print("\t",myDictionary)
print()
print("\tEnd of Program")

Multiply all the items in a dictionary in Python


Write a Python program to multiply all the items in a dictionary.

I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.unlimitedbooksph.com/

Program Listing



my_dictionary = {'data1':100,'data2':-54,'data3':247}
result=1
for key in my_dictionary:   
    result=result * my_dictionary[key]

print(result)

MERGE TWO PYTHON DICTIONARIES


Write a Python program to merge two Python dictionaries and display the results on the screen.
  
 I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.unlimitedbooksph.com/

Program Listing




print()
print("\tMERGE TWO PYTHON DICTIONARIES")
print()
d1 = {'a': 100, 'b': 200}
d2 = {'x': 300, 'y': 200}
d = d1.copy()
d.update(d2)
print(d)
print()
print("\tEND OF PROGRAM")

FINDING THREE HIGHEST VALUES IN A DICTIONARY IN PYTHON


Write a program to find the three highest values in a dictionary and display the result on the screen.


I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.unlimitedbooksph.com/

Program Listing



my_dict = {'A': 40, 'B': 60, 'C': 100,
           'D': 20, 'E': 90, 'F': 80}

k = Counter(my_dict)
# Finding 3 highest values
high = k.most_common(3)

print()
print("\tFINDING THREE HIGHEST VALUES IN A DICTIONARY")
print()
print("\tInitial Dictionary:")
print()
print("\t",my_dict, "\n")
print("\tDictionary with 3 highest values:")
print("\tKeys: Values")
print()
for i in high:
    print("\t",i[0],":", i[1],"")
    print()
print("\tEND OF PROGRAM”)

CREATING A NESTED DICTIONARY IN PYTHON


Write a program to create nested dictionary and display the result on the screen.

I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.unlimitedbooksph.com/

Program Listing



display_dictionary = {1: 'Fundamentals', 2: 'of', 3: 'Python Programming',
        4: {'A': 'Welcome', 'B': 'To', 'C': 'Bacolod City'}}
print()
print("\tCREATING A NESTED DICTIONARY")
print()
print("\tDISPLAY RESULT")
print()
print("\t",display_dictionary);
print()
print("\tEND OF PROGRAM").

COMBINE THREE DICTIONARY ADDING VALUES FOR COMMON KEYS IN PYTHON


Write a program to combine two dictionary-adding values for common keys and display the result on the screen.


I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.unlimitedbooksph.com/

Program Listing



from collections import Counter
a1 = {'a': 10, 'b': 20, 'c':30}
a2 = {'a': 20, 'b': 10, 'c':40}
a3 = {'a': 30, 'b': 40, 'c':20}

display_result = Counter(a1) + Counter(a2) + Counter(a3)
print()
print("\tCOMBINE THREE DICTIONARY ADDING VALUES FOR COMMON KEYS")
print()
print("\tDISPLAY RESULT")
print()
print("\t",display_result)
print()
print()
print("\tEND OF PROGRAM")

ITERATE OVER DICTIONARIES USING FOR LOOPS IN PYTHON


Write a program to iterate over dictionaries using for loops and display the result on the screen.


I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.unlimitedbooksph.com/

Program Listing




display = {'a': 5,'b':10,'c':15,'d':20,'e':25}

print()
print("\tITERATE OVER DICTIONARIES USING FOR LOOPS")
print()
print("\tDISPLAY RESULT")
print()
for dict_key, dict_value in display.items():
    print("\t",dict_key,'->',dict_value)
print()
print("\tEND OF PROGRAM")

ADD NEW ITEM IN THE DICTIONARY IN PYTHON



Write a program to add an item in the dictionary and display the result on the screen.

I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.unlimitedbooksph.com/

Program Listing

add_item =    {

  "brand": "Hyundai",
  "model": "Accent",
  "year": 2012
}

add_item["color"] = "red"
print()
print("\tADD NEW ITEM IN THE DICTIONARY")
print()
print("\tDISPLAY RESULT")
print()
print("  ",add_item)
print()
print("\tEND OF PROGRAM");



CHECK IF A GIVEN KEY ALREADY EXISTS IN A DICTIONARY IN PYTHON


Write a program to check if a given key already exists in a dictionary and display the result on the screen.


I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.unlimitedbooksph.com/

Program Listing



list = {1:5,2:10,3:15,4:20,5:25,6:30,7:35,8:40}

def check_key(a):
  if a in list:
      print('\tThe key {0} is present in the dictionary.'.format(a))
  else:
      print('\tThe key {0} is not present in the dictionary.'.format(a))

print()
print("\tCHECK IF A GIVEN KEY ALREADY EXISTS IN A DICTIONARY")
print()
print("\tDISPLAY RESULT")
print()
check_key(7);
print()
print("\tEND OF PROGRAM");

SUM OF ALL THE ITEMS IN THE DICTIONARY IN PYTHON


Write a program, take a dictionary, and print the sum of all the items in the dictionary and display the result on the screen.


I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.unlimitedbooksph.com/

Program Listing



print()
print("\tSUM OF ALL THE ITEMS IN THE DICTIONARY")
print()
display={'a':10,'b':20,'c':30,'d':40,'e':50}
print("\tDISPLAY RESULT")
print()
print("\tThe total sum is" ,sum(display.values()),".")
print()
print("\tEND OF PROGRAM”)