Ask Question
5 July, 02:08

Given that k and j each refer to a non-negative int and that play_list has been defined to be a list with at least j elements, write an expression that evaluates to a new list containing all the elements from the one at index k through the one at index j-1 of list play_list. Do not modify play_list.

+1
Answers (1)
  1. 5 July, 03:10
    0
    Following are the program in the Python Programming Language

    #list type variable

    play_list = [10,20,30,40,50,60,70,80]

    k=3 #integer type variable

    j=len (play_list) #integer type variable

    new_list=play_list[k:j] #solution is here

    print ("play_list: ", play_list) #print variable play_list

    print ("new_list: ", new_list) #print variable new_list

    Output:

    play_list: [10, 20, 30, 40, 50, 60, 70, 80]

    new_list: [40, 50, 60, 70, 80]

    Explanation:

    Here, we set the list type variable "play_list" and assign elements in it is [10,20,30,40,50,60,70,80] then, we set an integer type variable "k" and assign value is 3.

    Then, we set an integer type variable "j" and assign the length of the variable "play_list" in it. Then, set the list type variable "new_list" and assign the elements of the variable "play_list" after applying slicing on it. Finally, print the variable "play_list" and the variable "new_list".
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Given that k and j each refer to a non-negative int and that play_list has been defined to be a list with at least j elements, write an ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers