Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

ONE_TEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] def swapFirstLast (data): temp1 = data [0] data.reverse() temp2 = data[0] data[0] = temp1 data.reverse()...

ONE_TEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

def swapFirstLast (data):

  temp1 = data [0]

  data.reverse()

  temp2 = data[0]

  data[0] = temp1

  data.reverse()

  data[0] = temp2

def shiftRight (data):

  temp1 = data[0]

  length = len(data)

  data2 = []

  for i in range (length):

    data2.append(data[i-1])

  data = list(data2)

  print (data,'b')

def replaceEven(data):

  length = len(data)

  data2 = []

  for i in data:

    if i % 2 != 0:

      data2.append(i)

    else:

      data2.append(0)

  data = list(data2)

  print (data, 'c')

def main():

  print ("The original data for all functions is: ", ONE_TEN)

  data = list(ONE_TEN)

  swapFirstLast(data)

  print ("After swapping first and lst: ", data)

  data = list(ONE_TEN)

  shiftRight(data)

  print ("After shifting right: ", data)

  data = list(ONE_TEN)

  replaceEven(data)

  print("After replacing even elements: ", data)

if __name__ == "__main__":

  main()

why do i get a different output between

print(data, 'b') and main

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question