Common Computer Science References
Saving related data together in a single variable is an extremely helpful strategy.
Below is a list of possible problems that MUST be solved using some kind of list (or array). You need to pick one that no one else in the class has selected and solve this problem for the assignment. Do not wait until the last minute. You can not use any built in "functions" that will just solve the problem for you! Ex: if you are trying to find the max number in a list, no using "max" to solve it. You MUST use loops.
There are caveats:
You must pass the needed values in a list to a function to solve the problem, then get the function to return the answer
the function MUST use a loop to solve the problem
Your main program (not the function) must ensure valid input and not crash if invalid input is given, but warn the user and let them try again
You need to pick a problem that no one else has picked. Do not wait until the last minute. Also, you can not do one that we have already done in class.
If you are not sure of any part of the problem, just ask me and I will give you additional information.
I can get a bonus? Yes, you can!
If you complete just the above part of the assignment in Python, you will be marked out of 3+. You will be marked out of 4+ if you do the programming in C as well.
Write a function that uses a list that does something that you want! You must get my permission before you can pick this.
Write function that reverses a list.
Write a function that checks whether an element occurs in a list.
Write a function that returns the elements on odd positions in a list.
Write a function that tests whether a string is a palindrome.
Write a function that compute the sum of the numbers in a list.
Write a function square_all that applies the square operation to every element of a list that has integers in it. For example: [2,5,1,10,7] → [4,25,1,100,49]
Write a function that concatenates two lists. [a,b,c,d,e], [1,2,3] → [a,b,c,1,2,3,d,e]
Write a function that combines two lists by alternatingly taking elements, e.g. [a,b,c,d,e], [1,2,3] → [a,1,b,2,c,3,d,e].
Write a function that merges two sorted lists into a new sorted list. [1,4,6,7,9],[2,3,5] → [1,2,3,4,5,6,7,9]. You can do this quicker than concatenating them followed by a sort.
Write a function that rotates a list by k elements. For example [1,2,3,4,5,6] rotated by two becomes [3,4,5,6,1,2].
Write a function that takes a number and returns a list of its digits. So for 2342 it should return [2,3,4,2].
Write a function that takes a list of strings and prints them, one per line, in a rectangular frame. The fame needs to match the size of the text. For example the list ["Hello", "World", "in", "a", "frame"] gets printed as:
*********
* Hello *
* World *
* in *
* a *
* frame *
*********
Write function that translates a text to Pig Latin. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. “The quick brown fox” becomes “Hetay uickqay rownbay oxfay”.
Randomly generate a list of 100 integers from 1 to 50. Pass the list to a function that finds out how many are even. Return the number of even numbers.