Ask Question

Write a program for any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a space. Ex: If keysList = {32, 105, 101, 35} and itemsList = {10, 20, 30, 40}, print: 20 30.

+1
Answers (1)
  1. 3 May, 21:40
    0
    The solution code is written in Python:

    keysList = [32, 105, 101, 35] itemsList = [10, 20, 30, 40] output = "" for i in range (len (keysList)) : if (keysList[i] > 50) : output + = str (itemsList[i]) + " " print (output)

    Explanation:

    Firstly, let us use the two sample list, keysList and itemsList in our program (Line 1-2). Then create a output variable to hold the output string (Line 4).

    Next, we create a for-loop and use it to traverse through the elements in the keysList. If any keysList element is bigger than 50 then we use the same index i to get the corresponding item from itemsList and join that value to the output string (Line 7-8).

    Lastly, we print the output (Line 10).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a program for any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a space. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers