In: Computer Science
Python Programming- 9.11 S80 MT Practice1
#This is a template for practicing mutability and
conversion
#Create and assign the following list of numbers to a list data
type and variable name: 88.5, 90, 75, 70, 85.6
#convert the list to a tuple and assign the tuple a different
variable name
#Ask the user for a grade and convert it to a float type (no
prompt) and assign it to a new variable name
#append the user entered grade to the list
#update the tuple to reflect the user entered grade (Tip, replace
the entire tuple with the list converted to a tuple)
#compute the current average grade using the tuple
#Display the average that you calculated in the previous line using
the following format:
#Your average score is [calculated average]. (Tip: use the +
concatenator and convert the average to a string)
#Ask the user for another grade (no prompt), convert it to an
integer and assign it to a new variable name
#replace the third grade in the list with the most recently entered
grade (Tip, you'll need to use the index)
#remove the second grade from the list (Tip, you'll need to use the
index and the pop method)
#update the tuple to reflect these recent changes to the list (Tip:
replace the entire tuple with the converted list)
#compute the current average grade using the tuple (Tip: divide the
tuple sum by the tuple length)
#Display the latest average that you calculated in the previous
line using the following format:
#Your updated score is: [calculated average]. (Tip: use the +
concatenator and convert the average to a string)
#Display the following statement using the + concatenator using the
latest values for sum, length and average:
#(Tip: make sure all the three variables have been converted to
strings)
#With a total of [sum of tuple] for [length of tuple] assignments
your average score is [tuple average]!
#Create and assign the following list of numbers to a list data
type and variable name: 88.5, 90, 75, 70, 85.6
grades=[88.5, 90, 75, 70, 85.6]
#convert the list to a tuple and assign the tuple a different
variable name
gradesTuple = tuple(grades)
#Ask the user for a grade and convert it to a float type (no
prompt) and assign it to a new variable name
grade=float(input())
#append the user entered grade to the list
grades.append(grade)
#update the tuple to reflect the user entered grade (Tip, replace
the entire tuple with the list converted to a tuple)
gradesTuple = tuple(grades)
#compute the current average grade using the tuple
avgGrade=sum(gradesTuple)/len(gradesTuple)
#Display the average that you calculated in the previous line using
the following format:
#Your average score is [calculated average]. (Tip: use the +
concatenator and convert the average to a string)
print('Your average score is '+str(avgGrade))
#Ask the user for another grade (no prompt), convert it to an
integer and assign it to a new variable name
grade=int(input())
#replace the third grade in the list with the most recently entered
grade (Tip, you'll need to use the index)
grades[2]=grade
#remove the second grade from the list (Tip, you'll need to use the
index and the pop method)
grades.pop(1)
#update the tuple to reflect these recent changes to the list (Tip:
replace the entire tuple with the converted list)
gradesTuple = tuple(grades)
#compute the current average grade using the tuple (Tip: divide the
tuple sum by the tuple length)
avgGrade=sum(gradesTuple)/len(gradesTuple)
#Display the latest average that you calculated in the previous
line using the following format:
#Your updated score is: [calculated average]. (Tip: use the +
concatenator and convert the average to a string)
print('Your updated score is '+str(avgGrade))
#Display the following statement using the + concatenator using the
latest values for sum, length and average:
#(Tip: make sure all the three variables have been converted to
strings)
#With a total of [sum of tuple] for [length of tuple] assignments
your average score is [tuple average]!
print('With a total of '+str(sum(gradesTuple))+' for
'+str(len(gradesTuple))+" assignments your average score is
"+str(avgGrade)+"!")