Guest User

Untitled

a guest
Jun 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. # Homework #2 Mortal Combat
  2.  
  3. ## Preface
  4.  
  5. No console input this time. Do it all with hardcoded values.
  6.  
  7.  
  8. ## Problem 1
  9. Write a function that returns the largest element in a list.
  10.  
  11. Your program should work like this:
  12. ~~~python
  13. ## INPUT
  14. find_largest_in_list([1,2,3,4,5,99,1,3])
  15.  
  16. ## OUTPUT
  17. 99
  18. ~~~
  19. ---
  20. ## Problem 2
  21.  
  22. Write function that reverses a list, preferably in place.
  23.  
  24. Your program should work like this:
  25. ~~~python
  26. ## INPUT
  27. reverse([1,2,3,4])
  28.  
  29. ## OUTPUT
  30. [4,3,2,1]
  31. ~~~
  32.  
  33. ---
  34. ## Problem 3
  35.  
  36. Write a function that checks whether an element occurs in a list.
  37.  
  38. ~~~python
  39. ## INPUT
  40. find_in_list([1,2,3,4],3)
  41. ## OUTPUT
  42. True
  43. ~~~
  44. ---
  45.  
  46. ## Problem 4
  47.  
  48. Write a function that computes the list of the first 100 Fibonacci numbers.
  49.  
  50. ~~~python
  51. ## OUTPUT
  52. 1,2,3,5 ...
  53. ~~~
  54. ---
  55.  
  56. ## Problem 5
  57.  
  58. Write a function that tests whether a string is a palindrome.
  59.  
  60. ~~~python
  61. ## INPUT
  62. palindrome("racecar")
  63.  
  64. ## OUTPUT
  65. True
  66. ~~~
Add Comment
Please, Sign In to add comment