Hello folks.....!!!! As we have completed all the basic data
structures in python, now I am posting some exercises for you to
practice. Do practice and let me know if you face any difficulty.
These exercises are based on the concepts posted till yesterday....
Q1. Consider the string :
s1="I am learning python".
Capitalize the first letter of the word python. Use appropriate inbuilt methods.
Q2. Consider the following string :
s2="There was a lazy fox in the forest. The fox along with its family lived near the river. The lazy fox always slept and never brought food. So its family suffered from hunger."
Find the frequency of the words "fox", "lazy", "family", "river" . Construct a dictionary using this information.
Q3. Encrypting texts !!!! consider the string :
s3="Twinkle Twinkle little star"
Encrypt this string so that it becomes a secret message. What you have to do is reverse each word and join it back to get the secret string .
Q4. Consider two lists :
li_keys=['a','b','c','d']
li_values=['apple','ball','cat','data']
construct a dictionary out of these lists. eg :{'a':'apple'}
Q5. Consider the following strings
s1="He is MLA"
s2="University is in 2nd street"
s3="I saw bird"
Insert appropriate articles (a, an, the) at appropriate place and reconstruct the string.
Q6. li=['22','35','10','15','9']- Find the average of this list, after doing the necessary pre-processing steps.
Q7. Consider the strings :
s1="The cattle is grazing"
s2="The field looks like a green blanket over the earth"
combine the two strings, arrange the words in alphabetical order and make it into a single string.
Q8: Spot the errors : Correct the error make the code run.
code snippet 1:
a=dict(('a','apple'),('b','ball'),('c','cat'))
code snippet 2:
dict1={'a':1,'b':2,'c':3,'d':4}
del dict1['e']
Q9: Consider 4 alphabets : a,q,t,z. For each alphabet find 4 words with their synonym. Construct a dictionary of appropriate format, ie,. It must resemble an original dictionary.
Q10. For the admission in a college several students appeared. The courses and students who applied for it are given below :
maths={'a','b','c','d'}
phy={'b','e','z','q'}
cs={'a','f','g','d','k','r'}
che={'l','m','k','d'}
Find :
These exercises are based on the concepts posted till yesterday....
Q1. Consider the string :
s1="I am learning python".
Capitalize the first letter of the word python. Use appropriate inbuilt methods.
Q2. Consider the following string :
s2="There was a lazy fox in the forest. The fox along with its family lived near the river. The lazy fox always slept and never brought food. So its family suffered from hunger."
Find the frequency of the words "fox", "lazy", "family", "river" . Construct a dictionary using this information.
Q3. Encrypting texts !!!! consider the string :
s3="Twinkle Twinkle little star"
Encrypt this string so that it becomes a secret message. What you have to do is reverse each word and join it back to get the secret string .
Q4. Consider two lists :
li_keys=['a','b','c','d']
li_values=['apple','ball','cat','data']
construct a dictionary out of these lists. eg :{'a':'apple'}
Q5. Consider the following strings
s1="He is MLA"
s2="University is in 2nd street"
s3="I saw bird"
Insert appropriate articles (a, an, the) at appropriate place and reconstruct the string.
Q6. li=['22','35','10','15','9']- Find the average of this list, after doing the necessary pre-processing steps.
Q7. Consider the strings :
s1="The cattle is grazing"
s2="The field looks like a green blanket over the earth"
combine the two strings, arrange the words in alphabetical order and make it into a single string.
Q8: Spot the errors : Correct the error make the code run.
code snippet 1:
a=dict(('a','apple'),('b','ball'),('c','cat'))
code snippet 2:
dict1={'a':1,'b':2,'c':3,'d':4}
del dict1['e']
Q9: Consider 4 alphabets : a,q,t,z. For each alphabet find 4 words with their synonym. Construct a dictionary of appropriate format, ie,. It must resemble an original dictionary.
Q10. For the admission in a college several students appeared. The courses and students who applied for it are given below :
maths={'a','b','c','d'}
phy={'b','e','z','q'}
cs={'a','f','g','d','k','r'}
che={'l','m','k','d'}
Find :
- Total number of students appeared for the admission.
- The students who applied for both maths and physics.
- Number of students who applied for computer science but not for maths.
solution👉
Comments
Post a Comment