Dictionary: 1 to 10 Eng2Italian C#
Here is the C# version of this program
I started with a blank dictionary. These are also called associative arrays. It stores information by key and value.
Eng2Italian = {}
I added the key-value pairs. one is the key and the value is ‘uno.
Eng2Italian = {} Itl2English = {} temp = {} key_list = "" val_list = "" print(type(Eng2Italian)) Eng2Italian['one'] = 'uno' Eng2Italian['two'] = 'due' Eng2Italian['three'] = 'tre' Eng2Italian['four'] = 'quattro' Eng2Italian['five'] = 'cinque' Eng2Italian['six'] = 'sei' Eng2Italian['seven'] = 'sette' Eng2Italian['eight'] = 'otto' Eng2Italian['nine'] = 'nove' Eng2Italian['ten'] = 'dieci' print("English to Italian Dictionary") print(Eng2Italian) print("\nItalian to English Dictionary") for key, value in Eng2Italian.items(): Itl2English[value] = key print(Itl2English) print('The number 3 is', Eng2Italian['three']) x = str(Eng2Italian.get('eleven')) print (str(x)) if x == str('None'): print('Sorry, not in the dictionary') print('we can update the dictionary to add eleven') Eng2Italian.update({'eleven':'undici'}) Itl2English.update({'undici':'eleven'}) print("English to Italian Dictionary") print(Eng2Italian) print("\nItalian to English Dictionary") print(Itl2English)
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'} The number 3 is tre None Sorry, not in the dictionary we can update the dictionary to add eleven English to Italian Dictionary {'one': 'uno', 'two': 'due', 'three': 'tre', 'four': 'quattro', 'five': 'cinque', 'six': 'sei', 'seven': 'sette', 'eight': 'otto', 'nine': 'nove', 'ten': 'dieci', 'eleven': 'undici'} Italian to English Dictionary {'uno': 'one', 'due': 'two', 'tre': 'three', 'quattro': 'four', 'cinque': 'five', 'sei': 'six', 'sette': 'seven', 'otto': 'eight', 'nove': 'nine', 'dieci': 'ten', 'undici': 'eleven'} Process finished with exit code 0