Python Exercise 1--- Dictionary

 Python Exercise 1---

So, in this tutorial i.e. Python exercise 1 tutorial, what we have to do is, we have to create a dictionary, similar to the real-world dictionary. There is no limit to the definition you provide to any word as this exercise is just for your practice.


The details and functionalities that are essential and must be present are:

  • User will give a word as an input. Suppose that the word is present in your dictionary along with its definition or meaning.
  • The program will print the meaning or definition of that word.

For example:

The user inputs the word : “programming”

The output will be:

 "the process of writing computer programs"

Your main focus should be towards writing a neat and efficient code, using only the knowledge from our previously done tutorials.

CODE---

#Exercise 1---
dic = {"A":"Apple", "B":"Ball", "C":"Cat", "D":"Dog"}
print("The required meaning is")
inp1 = input()
print(dic[inp1])

"""Output---
The required meaning is
C
Cat"""

Comments

Popular posts from this blog

Python Exercise 7 --- "Snake, Water, Gun"

Python Tutorial 38 --- "Self & __init__() (Constructors)(OOPS 3)"

Python Exercise 4 --- "Number Guessing Game"