Write Code Questions

Write a function item_lister that takes in a list of at least three values, items, as a parameter. Set the first value to “First item”, set the second value to the original first value, and set the third value to its current value plus one (rounded to two decimals). (Note: the third value of items will only be numerical.) Then, return the modified list. For example, itemLister([2,4,6.222,8]) would return ['First item', 2, 7.22, 8].

Create a function item_lister that takes in a list of at least three values, items, as a parameter. Set the first value to “First item”, set the second value to the original first value, and set the third value to its current value plus one (rounded to two decimals). (Note: the third value of items will only be numerical.) Then, return the modified list. For example, itemLister([2,4,6.222,8]) would return ['First item', 2, 7.22, 8].

Write the function change_index3 that takes in one parameter, lst, and assigns the value at index 3 of lst to ‘200’ and then returns lst. For example, change_index3(['hi', 'goodbye', 'python', '106', '506']) would return ['hi', 'goodbye', 'python', '200', '506'] and change_index3([1, 2, 0, -5, 4]) would return [1, 2, 0, '200', 4].

Create the function change_index3 that takes in one parameter, lst, and assigns the value at index 3 of lst to ‘200’ and then returns lst. For example, change_index3(['hi', 'goodbye', 'python', '106', '506']) would return ['hi', 'goodbye', 'python', '200', '506'] and change_index3([1, 2, 0, -5, 4]) would return [1, 2, 0, '200', 4].

Write a function countWords that takes in a list, lst, as a parameter, and returns the amount of words that have a length of 5. For example, countWords(['hello', 'hi', 'good morning', 'three', 'kitty'] should return 3.

Create a function countWords that takes in a list, lst, as a parameter, and returns the amount of words that have a length of 5. For example, countWords(['hello', 'hi', 'good morning', 'three', 'kitty'] should return 3.

Write a function reverse that takes in one parameter, lst, and returns the reverse of a passed list. For example, reverse[1,2,3] should return [3, 2, 1].

Create a function reverse that takes in one parameter, lst, and returns the reverse of a passed list. For example, reverse[1,2,3] should return [3, 2, 1].

Write a function sort_by_length that takes in one parameter, a list of strings, lst, and returns the list sorted by the length of the strings. For example, sort_by_length(["hello", "hi", "hey", "greetings"]) would return ['hi', 'hey', 'hello', 'greetings'].

Create a function reverse that takes in one parameter, lst, and returns the reverse of a passed list. For example, reverse[1,2,3] should return [3, 2, 1].

You have attempted of activities on this page