daily pastebin goal
64%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 68 in 8 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Python Exercise 1  
  2. =================  
  3. You can write this in a fresh Python program, or use the interactive interpreter
  4. Create a tuple containing 'Jan', 'Feb' etc.
  5. Check you understand which index of the tuple contains 'April'
  6. Print the months in the third quarter of the year (Jul-Sep) using [n:m] and using [n:-m]
  7. Use 'input' to ask the user for a full name which you store in some global variable
  8. Force the name to title case using .title()
  9. Show them the reverse of whatever they typed by using [::-1]
  10. Store first_name and last_name by finding the index where the space occurs and getting the string up to
  11.  
  12. and then following the space. Try using negative indexes for the second parameter
  13. Ask the user their birthday month, then their birth date ( e.g. 1-31 ) and then year ( e.g. 1972 )
  14. CAUTION: we currently have no way to check so only enter actual months (as they appear in your list)
  15. Derive the index of the month and use that to build a date-like construct ( e.g. 15/9/1972 )
  16. Create a list containing the entered names, date, month and year
  17. Use print() to show details nicely formatted ( e.g. first: Toby, last: Dussek, birthday: 15-9-1972 )
  18. Ask the user to enter a middle name/initial (make one up if you have none)
  19. Insert this value in it's place within the existing list
  20.  
  21. Optional
  22. ========
  23. Explore string.split(' ') as an alternative way to create a list from a series of entered words
  24. Explore mutating the list using del, remove() and pop()
  25. Find how many times a given letter ( e.g. 'e' ) appears in the name using .count('e')
RAW Paste Data
Top