Instructor solution
Peer Responses
3.3 Lists - Lesson
You may exit out of this review and return later without penalty.
Unit 3: Types - Review Assignment
1.Write a function that returns if an input parameter test_string ends in ing.
2.Write a function that takes in two parameters, first_name and last_name, and returns a formatted string of the format "<first_name> <last_name>".
3.Replace the first 2 instances of the string "a" with the string "AYE" in the variable a_str.
4.Write a function that returns if the \(n^{th}\) character in a given string is a given character.
5.Write a function that concatenates two strings, with the longer string first.
6.What's wrong with the following string initialization?
python3<br>a = "I like apples'<br>
7.Print the third character of the string variable a_str if a_str is at least three characters long, or print "too short" otherwise.
8.Write code that prints the count of times the string "banana" appears in the list fruits.
9.What happens if you create a set in Python with duplicate values, such as a_set = {1, 2, 3, 1}?
10.Write a function that changes the value at given index i of a given list a_list to a given value new_value if the described conditions are met.
11.What's the difference between the list methods append and extend?
12.Remove the last element from the list a_list.
13.Identify each of the following data types in Python as mutable or immutable: lists, tuples, sets, dictionaries.
14.What's the difference between a tuple and a list in Python?
15.True or False: Dictionaries in Python can support keys of any type.
16.Can tuples contain duplicate values in Python?
17.Give an example of when you may want to use a tuple over a set? Give an example of when you may want to use a set over a tuple?
18.What's the difference between a list and a set in Python?
You may exit out of this review and return later without penalty.