Course Content

Python Exercise 1 - Apni Dictionary

So, guys this is our first tutorial in which I am going to give you a task as an exercise. I have designed a lot of exercises for you in the upcoming tutorials, by the help of which you can get an idea about your skills or learning, as each one of them covers the concepts we learned in the Tutorials before that.

So, in order for you to test yourself, you may take them as a challenge and upon their completion you can move forward. In case you are having any difficulty solving an exercise, you can always revisit the previously taken tutorials. So, in this way exercises will help you to evaluate yourself and will also provide a revision up to some level.

Problem Statement:

So, in this tutorial i.e. Python exercise 1 tutorial, what we have to do is 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.

I would encourage all of you to participate in solving this task. At least give it a try so you may have an idea about your progress, because the starting tutorials make the real basis for the upcoming one’s and if the basis aren’t strong, we can not achieve our desired goal of becoming a better python language programmer.

Comments(25)

SachinJ 1 year, 2 months ago
Tharoor= { "snollygoster": "https://en.wiktionary.org/wiki/snollygoster", 
          "rodomontade":"https://en.wiktionary.org/wiki/rodomontade",
          "puerile":"https://en.wiktionary.org/wiki/puerility",
          "farrago":"https://en.wikipedia.org/wiki/Farrago"}
word=input("Select a word from the above dictionary ")
print("Kindly go to the link, it will give you much more information than just meaning and synonyms of",word,"\n",   "Here is the link: ", Tharoor.get(word))
pawan 1 year ago
d2 = {"Cause-and-effect diagram":"https://en.wikipedia.org/wiki/Ishikawa_diagram",
      "Check sheet":"https://en.wikipedia.org/wiki/Check_sheet",
      "Control chart":"https://en.wikipedia.org/wiki/Control_chart",
      "Histogram":"https://en.wikipedia.org/wiki/Histogram",
      "Pareto chart":"https://en.wikipedia.org/wiki/Pareto_chart",
      "Scatter diagram":"https://en.wikipedia.org/wiki/Scatter_plot",
    "Stratification":"https://en.wikipedia.org/wiki/Stratification"}
print("Enter the QC Tool Name:")
print(d2[input()])

white_devil 11 months ago
dict1 = {"Harry": "Programmer", "Priyanshu": "Py Learner", "Larry": "Js Learner", "Carry": "Android Developer"}
print("Copy One Of The Name And Paste It")
print("1) Harry", "2) Priyanshu", "3) Larry", "4) Carry")
a = input()
print(dict1[a])
Manav_Seng 9 months, 1 week ago
Python Excercise 1 apni dictionary
Name:Manav Sengupta
Solution(Copy and paste  everything below):

#This is the Question given by CodeWithHarry Channel #Python Excercise 1 #ApniDictionary
#The following is the solution
Word=['Tensor','Diffusion','Quantum','Calculus','Lemma']# Words
Meanings=['A Rank n Tensor in m dimensions is a mathematical object which has n indices and m^n components which follow certain mathematical transformation rules','Diffusion is defined as the movement of substances from a region of higher concentration to a region of lower concentration down an concentration gradient','The smallest amount of a quantised quantity like charge is called its quantum','Calculus is the Branch of Mathematics which deals with the nature of change and allows to perform various mathematical operations on it','A Lemma is a proven statement used to prove other statements'] # Respective Meanings
ApniDictionary={Word[0]:Meanings[0],Word[1]:Meanings[1],Word[2]:Meanings[2],Word[3]:Meanings[3],Word[4]:Meanings[4]} #Creation of Dictionary
input_word=input("Enter Your Word") #User Input
temp=input_word.capitalize() #Presentation Purposes
#Input should be in lower case
print("\n"+ temp+" : "+ApniDictionary[temp]+"\n") #Final Output
print(147*"*"+"\n*"+145*" "+"*\n*"+9*" "+"Thanks for checking out my code, and a ton of thanks to CodewithHarry Channel for all the Quality Content for Free"+22*" "+"*\n*"+145*" "+"*\n"+147*"*") # Gratitude
#Run the Code with the Run Terminal or Console enlarged more than default as the output take some space

#The excercise could be done in lesser code but to balance preentation and code size which are tradeoffs, I think this solution is in the sweet spot.
#Feel free(anyone) to give reviews and suggestions to the above exercise, Constructive critisizim is appreciated , but critisize ideas not people.
zadrain 8 months, 2 weeks ago
x={"life":"a different journey for every humenbeing ",
   "death":"the action or fact of dying or being killed; the end of the life of a person ",
   "marriage":"the legally or formally recognized union of two people as partners in a personal relationship (historically and in some jurisdictions specifically a union between a man and a woman",
   "education":"the process of receiving or giving systematic instruction, especially at a school or university."}
print(x[input("type here in lower case")])
arnavc06 6 months, 1 week ago
Helpful
nazishali 7 months, 2 weeks ago
# create a dictionary and take input from the user and return the meaning of the word from the dictionary
print("for making a dictionary input 5 string")
a1 = input()
m1 = input("Enter meaning of the word:")
a2 = input()
m2 = input("Enter meaning of the word:")
a3 = input()
m3 = input("Enter meaning of the word:")
a4 = input()
m4 = input("Enter meaning of the word:")
a5 = input()
m5 = input("Enter meaning of the word:")
dict4 = {a1:m1,a2:m2,a3:m3,a4:m4,a5:m5}
a7 = input(print("search from dictionary:"))
if a7 in dict4:
    print(dict4.get(a7))
saswata 7 months ago
import wikipedia
dict = {'virus':'https://en.wikipedia.org/wiki/Virus',
        'asteroid':'https://en.wikipedia.org/wiki/Asteroid',
        'AI':'https://en.wikipedia.org/wiki/Artificial_intelligence'
        }
word = list(dict.items())
print(word)

word = input('Enter thr word: ')
for i,j in dict.items():
    if (word==i):
        print(wikipedia.summary(j, sentences=2))
    else:
        print('Sorry')
    
iammsami 6 months ago
Harry bhai 
#creating a dictionary with words and meanings
d1 ={"Mutable":"Which Changes","Immutable" : "Which doesn't Change","Luminous":"Object with Light","Sonorous" : "Sound Producing Utencils"}
print("Enter the word to which you want meaning")
print(d1[input()])
#ye print(d1[input()]) ke badle kch oor use nae krsakte kya
Vivek-Mishra 5 months, 1 week ago
Full Notes and Source Code ::::::::::} https://github.com/Optimized-World/Complete-Python-Tutorial-and-Notes |::::::::::::| Thanks, Harry Bhai for Awesome Tutorials
Aniketkasale 5 months, 1 week ago
# Create a dictionary and take input from the user and return the meaning of the
# word from the dictionary

d1={"Adorable":"पूजनीय","Aggressive":"क्रोधी","Anxious":"चिन्तित","Artistic":"कलात्मक"}
print("Enter Any word(Adorable,Aggressive,Anxious,Artistic)")
a = input()
if a == "Adorable" :
    print(d1["Adorable"])
elif a=="Aggressive":
    print(d1["Aggressive"])
elif a=="Anxious":
    print(d1["Anxious"])
elif a=="Artistic":
    print(d1["Artistic"])
else:
    print("word does not exist in dictionary")

dpkpdy 4 months, 3 weeks ago
dct1={'Mutable':'can change', 'Imutable':'That can not change', 'Abort':'Terminate','Fault':'Mistake'}
word=input()
print(dct1[word])
sanam007 4 months, 2 weeks ago
d1 = {"mutable":"can change", "immutable":"cannot change", "bug":"problem", "software":"application"}

user = input('ENTER YOUR WORD: ')

print(user, "means", d1[user],".")
broogle 4 months, 2 weeks ago
d1={"stump":"cricket accessory","mobile":" device","volvo":"car company","TCS":"Tata Consultancy Services"}
a=input("Enter the word you want to search:")
print(d1[a])
rahul87 4 months, 2 weeks ago
# Dictionary is nothing but key value pairs
d1 = {"set":"https://www.w3schools.com/python/python_sets.asp",
      "tuplse":"https://www.w3schools.com/python/python_tuples.asp",
      "list":"https://www.w3schools.com/python/python_lists.asp",
      "syntax":"https://www.w3schools.com/python/python_syntax.asp",
      "variables":"https://www.w3schools.com/python/python_variables.asp",
      "comments":"https://www.w3schools.com/python/python_comments.asp"}
a=input()
print(d1[a])
rahul87 4 months, 2 weeks ago
how to open link page in crome
hipsane1 4 months, 1 week ago
user_dict = {"liberty":"he state of being free within society from oppressive restrictions imposed by authority on one's way of life, behaviour, or political views",
             "association":"a group of people organized for a joint purpose",
             "park":"a large public garden or area of land used for recreation.",
             "sets":"A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets."
             }
user_input = input("Enter a word to search:\n")
user_output = user_dict.get(user_input)
print(user_output)
himanshu9 4 months, 1 week ago
dict={"Degrees":"Level,Step",
        "Appreciate":"praise",
        "Possessed":"Had,Owned",
        "Well Wisher":"Good wisher"
    }
input_user=input("enter the word for the meaning:").capitalize()
print(input_user,"=",dict.get(input_user))
exit=input("Press w key to exit or want to continue then press o :")
shellstar 4 months ago
mall = {"nirma":"40Rs",
        "soap":"20Rs",
        "parle G":"10Rs",
        "sugar":"80Rs"}
print("what you want to buy from our mall?"
      "\navailable Products= nirma,soap,parle G, sugar.")
mall2 = input()
if mall2 == "nirma":
 print("nirma price is ")
 print(mall["nirma"])
if mall2 == "soap":
 print("soap price is ")
 print(mall["soap"])
if mall2 == "parle G":
 print("parle G price is ")
 print(mall["parle G"])
if mall2 == "sugar":
  print("sugar price is ")
  print(mall["sugar"])
shellstar 4 months ago
mall = {"nirma":"40Rs",
        "soap":"20Rs",
        "parle G":"10Rs",
        "sugar":"80Rs"}
print("what you want to buy from our mall?"
      "\navailable Products= nirma,soap,parle G, sugar.")

print(mall[input()])
rahulerys 3 months, 3 weeks ago
dictionary = {"Sets": "In mathematics, a set is a well-defined collection of distinct objects, "
                      "considered as an object in its own right. The arrangement of the objects in the set does not"
                      " matter. A set may be denoted by placing its objects between a pair of"
                      " curly braces. Wikipedia",
              "Apple": "Apple has two things in this world called as,"
                       "the first Apple we calls is a fruit,"
                       "& the Second Apple we calls is Tech-Company Apple",
              "Football": "A Football is, a ball human hits it by foot and the players aims to hit the "
                          "ball into the net of opposite team. As player hits the football into the net of "
                          "opposite team it counts as a goal a point for the team who hit the ball into opposite net ",
              "Motivation": "Motivation is the experience of desire or aversion. "
                            "As such, motivation has both an objective aspect and "
                            "an internal or subjective aspect. Wikipedia"


              }

print(dictionary.get(input("Type Here : ")))
ankit100 3 months, 1 week ago
sir enjoying python very much
shadysoul 3 months ago
Dict=["anoymous:Hidden","Check:Confirm","Invalid:Incorrect"]
print("Dictionary")
print("1.Anoyamous")
print(input())
print("Answer")
print(Dict[0])
print("2.Check")
print(input())
print("Answer")
print(Dict[1])
print("3.Invalid")
print(input())
print("Answer")
print(Dict[2])
abhi1584 2 months, 1 week ago
meanings = {"apple":'the round fruit of a tree of the rose family, which typically has thin green or red skin and crisp flesh', "pen": 'an instrument for writing or drawing with ink', "deodorant": 'a substance which removes or conceals unpleasant smells'} #Declaring the meanings Dictionary

print('*****Dictionary*****')

# Taking the input from the User
userInput = input('Enter the word you Want to Search : ')

print(meanings[userInput]) 
aadvik996 3 weeks, 4 days ago
h

Resources

No downloadable resources for this video. If you think you need anything, please post it in the QnA!

Course Announcements

Any Course related announcements will be posted here