Wk 1: TUE 4 SEP - MON 10 SEP
Reviewing the essential built-in types in Python
- How do Python's built-in type set compare to other languages you know?
- What are the definining features of tuples, lists, and dictionaries?
- Create and manipulate small quantities of data in tuples, lists, and dictionaries
- Process Strings with slicing and built-in methods on String objects
- Creatively engineer a program for storing and displaying information about our classmates
listBuilt-in types opening activity
The Python types that we'll review tonight:
The challenge specification:
- Design a dictionary whose keys describe what values you'd like to learn about your peers in this class. Design the dictionary on paper, specifying the data type of the value. You must store at least one of each of our review types.
- Once the specification is done, pass the dictionary design to a peer, and ask them to populate the dictionary values with appropriate syntax.
- Now, at a computer, create a simple program which creates this dictionary, whose keys are all strings, and hard-code the values from yet a third person's dictionary.
- Create a simple mechanism for retrieving the value of one of the keys in the dictionary using user input.
- Prepare to demonstrate your program to your peers.
listString slicing exercise
- Write a short program that reads in a String and prints out the first two followed by the last two letters of this string only. Before performing this operation, check to make sure the user entered a String of at least 4 letters. If it's too short, reject the input and end the program.
- Write a program that checks to see if the second and second-to-last letter of an inputted string are the same letter. If so, print a corresponding message to the user. If not, terminate with an ominous message.
- Ask the user for three strings. Input these into three different String variables. Once you have the data, print out these three strings on one line, organized from the shortest to the longest words. If words are the same length, the order is irrelevant.
listLooping review exercise
This exercise is intended to provide a review of basic looping and listing facilities in Python. If this exercise is a challenge, that's okay--it's a check-in exercise!
- Envision on paper using pseudocode a program which asks the user for an integer. The program then should display the a list that counts from 0 up to this given integer. Finally, the program should display the total of each of the elements of this list added together.
- Code the program in Python and test it
- Study the sample output for help
Sample program interaction
- If these exercises were challenging, please make sure you come next week with attempted code for each and questions you have to complete the exercises.
- Create a custom data type using nested dictionaries that stores information about a topic of your choosing that you find interesting. Prepare a hard-coded sample of a datum using this particular dictionary scheme.
Revisit with gusto the differences between the various python Built-in types.
arrow_upwardback to schedule