Programming Languages Exercise 4 Solution

Send your codes to the instructor via e-mail. Make a single script file that includes example results as comments. Add your name and the session, (morning/afternoon) ([email protected]) Google or any other search engine use is not allowed. Internet copy-paste answers will be scored 0 as well as anonymous files you send. Just mathematical solutions will not be accepted.






















(100pts) The following listings show how one might solve the following puzzle:



Look through a file of words, one word per line, and identify any English word that has all the vowels in order, with only one example of each vowel.




For example, “abstemious”, “abstentious”, “facetious”.




Your task* is to identify any word that matches this order, and print it to the screen.
















* Do not use Python lists, and str.find() method. Your text file should be named as “dictionary.txt”







Some hints:




To create a file with some example words, see Wikipedia for the full list of these words:




https://en.wiktionary.org/wiki/Category:English_words_that_use_all_vowels_in_alphabetical_order







You can consider strings as character sets, and files as word sets, for FOR loops, and IF statements;




if character in string
for character in string etc…



To measure the length of a string; len(string)




To concatenate strings you can use + operator




You can consider every word contains lowercase letters. If not, you should convert them to lowercase letters.




Some useful string methods:




string.lower() convert all characters to lowercase.




string.strip() #removes leading and ending white space