List Exercises

List Exercises

Exercise #1


nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]


If the number 5 is in the list print “list has 5”


Solution


Exercise #2


nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]


Add 3 to each number in the list

Solution


Exercise #3


nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]


Make each number in the list an even number

Solution


Exercise #4


nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]


Change the odd numbers to even numbers but leave the even numbers the same

Solution


Exercise #5


word = “Kerfuffle”


Write a program that prints each letter in word

Solution


Exercise #6


word = “Kerfuffle”


Write a program that makes every other letter of word capital.

Example : KeRfUfFlE

Solution


Exercise #7


nums = [86, 71, 62, 93, 54, 78, 93, 121, 104, 125, 89]


Write a program that prints out all the elements of nums that are less than 75

Solution


Exercise #8


nums = [86, 71, 62, 93, 54, 78, 93, 121, 104, 125, 89]


Write a program that takes the elements in nums and converts them to letters or characters.

Solution