QUESTIONS AND CORRECT ANSWERS
GRADED A+
● Object-Oriented Programming Goals. Answer: Combining data and
actions into an object
● Making Classes. Answer: class X:
sound = "meow"
def __init__(self, ect.)
self.ect = ect
def speak(self)
print("It's", self.ect)
Y = X(ect)
Z = X(ect)
print(y.ect)
print (X.sound)
● Objects are.... Answer: data and actions
● Actions are.... Answer: functions that belong to the class (methods)
, ● Methods can use.... Answer: the data in the object (instance variables)
● Ways to Work with Strings. Answer: Make them
Get a character with an index
Join two strings
Get substrings [1:3]
Loop over a string
Check if a letter is in a string
Check if one string is in another
Check were one string is in another
Make all lowercase/uppercase/ect
● Locate where one string is in another. Answer: name.index("vi") -> 2
(where "v" is located in "David")
● .split(). Answer: splits strings
default splits at spaces, can add letters in the () to change this
Produces lists
● .join(). Answer: Combines strings in a list into a larger string
my_string = " ".join(my_list)