Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write in python idle 3.5 nothing else very new to this topic please be very spec

ID: 3791790 • Letter: W

Question

write in python idle 3.5 nothing else very new to this topic please be very specific and detail each part

Eile Edit Yew Hbtory Bookmarks bols Help x Las Vegas odds Sports Sc x Free Daily Sports Picks fro. x SakaieURI: cso 110spri. x e sts-f x uriedu/access/lessonbuilderitem/11693721/group/e3dbb580-16f5-490f-aft0-88196032a87c/Labs/Lab 3 Using Lists 9 23 /lab3-lists-f 16.pdf https sakai. 3 of 3 PART 3: (CHALLENGED Merging Sorted Lists Write an algorithm that takes two sorted lists of integers and merges them into a single sorted list. You can start with the following two lists, but the program should work for any two sorted lists of integers. list1 [1, 4, 6, 7, 9, 11, 15 list2 2, 3, 4, 5, 10, 11, 12 Instructor Initials: PART 4: (CHALLENGED Reversing a List Write an algorithm that takes a list of numbers and the result is the same numbers stored in the same list in reverse order. After reversing the numbers in the list, print out the updated list. You can assume that you also are given the size of the list. While it is possible to do this by creating a second list, see if you can write the algorithm so that it does not need to use another list to create the result. That is, reverse the numbers using the existing list. ou may not use the reverse function available in python). Instructor Initials:

Explanation / Answer

program 1

def merge_list(list1,list2):

    #empty list declaration
    m_list=[]

    # adding the contents of list1 and list2 into m_list[]
    m_list.extend(list1)
    m_list.extend(list2)

    #sorting the m_list using sort() function
    m_list.sort()

    #printing the sorted merged list
    print('sorted merge list is ' + str(m_list))


if __name__=="__main__":

    # getting number of elements for list1 using input function
    n1=int(input('Enter the number of elements for list1... '))

    # empty list declaration
    list1=[]
    print('Enter the elements for the list 1')

    # getting elements for the list1 using for loop
    for i in range(n1):
        e=int(input('Enter the element '))
        list1.append(e)

    # getting number of elements for list1 using input function  
    n2=int(input('Enter the number of elements for list2... '))

    # empty list declaration
    list2=[]
    print('Enter the elements for the list 2')

    # getting elements for the list2 using for loop
    for i in range(n2):
        e=int(input('Enter the element '))
        list2.append(e)

    # sorting the two lists using built-in sort() function
    list1.sort()
    list2.sort()

    #calling the merge_list function sending the list as arguments
    merge_list(list1,list2)
      
SAMPLE OUTPUT

Enter the number of elements for list1... 3
Enter the elements for the list 1
Enter the element 10
Enter the element 9
Enter the element 13
Enter the number of elements for list2... 3
Enter the elements for the list 2
Enter the element 99
Enter the element 76
Enter the element 23
sorted merge list is [9, 10, 13, 23, 76, 99]

PROGRAM 2

def reverse_list(num_list):

    #printing the unreversed list
    print('the initial list is '+ str(num_list))
    t=0

    #finding the length of the list
    j=len(num_list)-1

    #iterating the list
    for i in range(0,(len(num_list)-1)):

        #checking for reaching the middle of the list
        if i < j:
            t=num_list[i]
            num_list[i]=num_list[j]
            num_list[j]=t
            j=j-1
    print('the reversed list is '+str(num_list))
          
  

if __name__=="__main__":

    #getting the number of elements for the list
    n=int(input('Enter the size of the list '))
    print('Enter the elements for the list')

    #empty list declaration
    num_list=[]

    #getting elements for the list using for loop
    for i in range(n):
        e=int(input('Enter the element '))
        num_list.append(e)

    #calling the function
    reverse_list(num_list)
      

SAMPLE OUTPUT

Enter the size of the list 5
Enter the elements for the list
Enter the element 12
Enter the element 6
Enter the element 89
Enter the element 22
Enter the element 43
the initial list is [12, 6, 89, 22, 43]
the reversed list is [43, 22, 89, 6, 12]