Question: using python 3 def calcLetterGrade( sc): if sc >= 90: return A elif sc >= 80: return B elif sc >=70: return C elif sc
using python 3
| def calcLetterGrade( sc): if sc >= 90: return A elif sc >= 80: return B elif sc >=70: return C elif sc >=60: return D else: return F
scList = [100, 81, 95, 67, 40, 78] gradeList = [ calcLetterGrade(sc) for sc in scList ] print(gradeList) |
|
| Use list comprehension to change all characters in a text file to lowercase: myFile = open (fileName,"r"); text = myFile.readlines(); text = [string.lower() for string in text]
| |
| Use list comprehension to create a myList which consists of the positive integers 1-100. Use list comprehension to create myListEvens which consists of all entries in myList that are even.
| |
| Use list comprehension to create a list of cubes of the integers 1-5.
| |
| Sentence = The cow jumped over the moon Create a list of the words in that sentence. Use list comprehension to create a list of each word in ALLCAPS, all_lowercase, and the count)
| |
| Use list comprehension to make a list of the first letter of each word in the following list: wordList = [this, is, an, example] |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
