6) Write the Python Code which can answer the following questions (20 pts):
a)Consider a program which contains a list of numbers from 1 to 10that are stored into a variable a. Create a program that will allow you to exchange the elements from variable a at position 0 and 7from within this list.
b)Create a program that will access the last 5 elements of the variable a from step a.)
# Part a a = [] for i in range(1,11): a.append(i) # Printing value of a print(a) # exchange the elements from variable a at position 0 and 7 from within this list a[0], a[7] = a[7], a[0] # Printing value of a print(a) ############################## # Part b # Code to access the last 5 elements of the variable a from step a print(a[-5:])
Get Answers For Free
Most questions answered within 1 hours.