Dictionary: 1 to 10 Eng2Italian C#
Dictionary: 1 to 10 Eng2Italian Py
Here is the python code for the same program
using System; using System.Collections.Generic; namespace dictionary { class EngToItalian { static public void Main() { DictionaryEng2Italian = new Dictionary () { {"one", "uno"}, {"two", "due"}, {"three", "tre"}, {"four", "quattro"}, {"five", "cinque"}, {"six", "sei"}, {"seven", "sette"}, {"eight", "otto"}, {"nine", "nove"}, {"ten", "dieci"} }; Dictionary Itl2English = new Dictionary () { }; foreach(KeyValuePair ele in Eng2Italian) { Itl2English[ele.Value] = ele.Key; } Console.WriteLine("English to Italian Dictionary"); foreach(KeyValuePair ele in Eng2Italian) { Console.WriteLine("{0}: {1}", ele.Key, ele.Value); } Console.WriteLine("\nItalian to English Dictionary"); foreach(KeyValuePair ele in Itl2English) { Console.WriteLine("{0}: {1}", ele.Key, ele.Value); } Console.WriteLine("\nTotal key/value pairs"+ " in Eng2Italian are : " + Eng2Italian.Count); if (Eng2Italian.ContainsValue("cinque")==true) { Console.WriteLine("cinque is found...!!"); } else { Console.WriteLine("cinque is not found...!!"); } if (Eng2Italian.ContainsKey("five")==true) { Console.WriteLine("five is found...!!"); Console.WriteLine("five: {0}",Eng2Italian["five"] ); } else { Console.WriteLine("five is not found...!!"); } if (Eng2Italian.ContainsKey("eleven")==true) { Console.WriteLine("eleven is found...!!"); Console.WriteLine("eleven: {0}",Eng2Italian["eleven"] ); } else { Console.WriteLine("\neleven is not found...!!"); Console.WriteLine("We can add eleven"); Eng2Italian["eleven"] = "undici"; Console.WriteLine("eleven: {0}",Eng2Italian["eleven"] ); Console.WriteLine("\nTotal key/value pairs"+ " in Eng2Italian are : " + Eng2Italian.Count); } } } }
English to Italian Dictionary one: uno two: due three: tre four: quattro five: cinque six: sei seven: sette eight: otto nine: nove ten: dieci Italian to English Dictionary uno: one due: two tre: three quattro: four cinque: five sei: six sette: seven otto: eight nove: nine dieci: ten Total key/value pairs in Eng2Italian are : 10 cinque is found...!! five is found...!! five: cinque eleven is not found...!! We can add eleven eleven: undici Total key/value pairs in Eng2Italian are : 11