python问题求助!
1.whatstatementswouldyoutypeatthePythonpromptinordertomakealistnamedrandNumsfilledwit...
1. what statements would you type at the Python prompt in order to make a list named randNums filled with 100 random integers taking value either -1 or 1? write a function randomItemFormList(L) that takes list L as parameter, and returns a random item from within the list.
2. create a dictionary cyclicLetterDict with keys equal to the lower case letters and values equal to the upper case letters one letter ahead in the alphabet(cyclically, so that 'z':'A' is pair)must use a for loop and not write out the whole dictionary by hand.
3. write a function checkForAllChars(s, alphabet)that returns True if all the characters of string alphabet are contained in string s and False otherwise.
4. write a function isWordPalindrome(word) which returns True if word spelled backwards is the same as word itself, and False otherwise. e.g. word='kayak', 'radar' or 'abba', function should return True.
5. write a function isWordBig(word, N) which returns Trues if word length is greater than or equal to N, False otherwise.
write a function findBigWords(N, filename) that returns a dictionary D with keys equal to words of length greater than or equal to N in file filename and values equal to the line number where each word was found. findBigWords should call your helper funcion isWordBig from part above, don't worry about the fact that the same big word might occur on multiple lines.
谢谢 我把分全都给你 展开
2. create a dictionary cyclicLetterDict with keys equal to the lower case letters and values equal to the upper case letters one letter ahead in the alphabet(cyclically, so that 'z':'A' is pair)must use a for loop and not write out the whole dictionary by hand.
3. write a function checkForAllChars(s, alphabet)that returns True if all the characters of string alphabet are contained in string s and False otherwise.
4. write a function isWordPalindrome(word) which returns True if word spelled backwards is the same as word itself, and False otherwise. e.g. word='kayak', 'radar' or 'abba', function should return True.
5. write a function isWordBig(word, N) which returns Trues if word length is greater than or equal to N, False otherwise.
write a function findBigWords(N, filename) that returns a dictionary D with keys equal to words of length greater than or equal to N in file filename and values equal to the line number where each word was found. findBigWords should call your helper funcion isWordBig from part above, don't worry about the fact that the same big word might occur on multiple lines.
谢谢 我把分全都给你 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询