Uploaded by shrikant.palekar

Quiz-Comprehensions.docx

advertisement
PLEASE SOLVE THE BELOW QUESTIONS USING
LIST/SET/TUPLE/DICTIONARY COMPREHENSIONS ONLY
1. Find all of the numbers from 1-1000 that are divisible by 7
2. Find all of the numbers from 1-1000 that have a 3 in them
3. Count the number of spaces in a string
4. Remove all of the vowels in a string
5. Find all of the words in a string that are less than 4 letters
6. Use a dictionary comprehension to count the length of each word in a sentence.
7. Create a list of all consonants in the sentence 'The quick brown fox jumped over the lazy dog'
8. Create a list of all the capital letters (and not white space) in 'The Quick Brown Fox Jumped Over
The Lazy Dog'
9. Create the list : [-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0]
10. Find age of people born in the year given in the list
years_of_birth = [1990, 1991, 1990, 1990, 1992, 1991]
Download