Ask Question
10 June, 08:11

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. 10 June, 11:17
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers