MCQs > IT & Programming > Python > Output of the following Python code? lstx = range(1, 11) print(lstx) lst1_x5 = lstx[1 : 5] print (lst1_x5) lst5_x = lstx[5 : 8] print (lst5_x) lst1_y = lstx[1 : ] print (lst1_y) lst_x5 = lstx[: 5] print (lst_x5) lst1_8_2 = lstx[1 : 8 : 2] print (lst1_8_2) lst_rev = lstx[ : : -1] print (lst_rev) lst_rev_9_5_2 = lstx[9 : 4 : -2] print (lst_rev_9_5_2)

Python MCQs

What will be the correct output of the following Python code?

lstx = range(1, 11)

print(lstx)

lst1_x5 = lstx[1 : 5]

print (lst1_x5)

lst5_x = lstx[5 : 8]

print (lst5_x)

lst1_y = lstx[1 : ]

print (lst1_y)

lst_x5 = lstx[: 5]

print (lst_x5)

lst1_8_2 = lstx[1 : 8 : 2]

print (lst1_8_2)

lst_rev = lstx[ : : -1]

print (lst_rev)

lst_rev_9_5_2 = lstx[9 : 4 : -2]

print (lst_rev_9_5_2)


Answer

Correct Answer:

range(1, 11)

range(2, 6)

range(6, 9)

range(2, 11)

range(1, 6)

range(2, 9, 2)

range(10, 0, -1)

range(10, 5, -2)  


Explanation:

Note: This Question is unanswered, help us to find answer for this one

Python Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Python Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it