



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




































Section 1: Original Questions Improved
Cor rec t Ratio nale O 1 Python provides a wide variety of tools and programmin g techniques that you can use to __ and __ strings. examine; manipula te delete; compile import ; print index; tokenize
Python include s many string method s for examini ng and manipul ating text. O 2 Strings use ___ to access individual characters. slicing indexing concat enatio n tokeniza tion
Indexin g uses bracket notatio n to
rec t Ratio nale access a charact er by position . O 3 In Python strings are __ meaning that the first character has index __, the second has index __, and so on. one- indexed; 1; 2 zero- indexed; 0; 1 negativ e- indexe d; - 1; 0 mutable ; 0; 1
Python sequen ces are zero- indexed . O 4 When iterating through a string with a while loop in Python, the loop continues until ___. a sentinel value is found the end of the string is reached the index equals 1 the string become s mutable
The loop stops when the index reaches the length of the string.
rec t Ratio nale d in place. O 8 String slices are called ___. substring s indexes tokens method s
substrin g is a contigu ous slice of a string. O 9 The expression string[start:e nd] includes characters with ___, not including the ending indexing position. the starting indexing position up to the ending indexing position only the ending position all positio ns except the start negative position s only
Slicing include s the start index and exclude s the end index. O 1 0 You can test to see if one string is contained in another string with in is == + A in returns True if a substrin g exists inside
rec t Ratio nale the ___ operator. another string. O 1 1 The string testing method ___ returns true if the string contains only numeric digits and is at least one character in length. isalpha() isdigit() isspace () isalnum ()
isdigit() checks whethe r all charact ers are digits. O 1 2 By default, the split method uses the ___ character as the delimiter. comma whitespa ce period tab only B str.split( ) splits on any whitesp ace by default. O 1 3
programs concentrate on creating objects which are Procedur al Object- oriented Functi onal Modula r
Object- oriente d progra mming centers
rec t Ratio nale only exposing what is necessary. object state. O 1 7 A(n) ___ is not a stand- alone program; it is used by programs that need its services. object operatin g system compil er spreads heet
Objects are used by progra ms and are not standal one applicat ions. O 1 8 A ___ is code that specifies the data attributes and methods for a particular object. class string list datafra me
A class is a bluepri nt for objects.
rec t Ratio nale O 1 9 Each object that is created from a class is called an ___ of the ___. instance; class class; instance metho d; object attribut e; method
An object is an instanc e of a class. O 2 0 A blueprint or template for creating objects, but it does not provide the main body of the program’s execution, is a ___. class function modul e loop A A class defines structur e but is not the progra m entry point. O 2 1 T/F: Class names must start with a capital letter. True False Only in Python 2 Only for built-in classes
Capitali zing class names is a convent ion, not a
rec t Ratio nale indexin g. O 2 5 Checking passwords is an example of ___ testing. String testing Class testing DataFr ame testing Loop testing
Passwor d validati on checks string content and format. O 2 6 How does a for loop know to stop? When the sequenc e is exhauste d When a sentinel blank always appears When the index equals 1 When the string become s mutable
A for loop stops after all items in the sequen ce are process ed. O 2 7 You must use ___ when iterating a len split join upper A len() gives the stoppin g
rec t Ratio nale string with a while loop. conditio n for the index. O 2 8 You (can/can’t) edit a string. can can’t only with appen d only with replace in place
Strings are immuta ble, so they have no append method . O 2 9 How do you edit a string? Delete the old string and replace it with a new string Use append Chang e a charac ter by index Use pop A Becaus e strings are immuta ble, editing creates a new string.
rec t Ratio nale O 3 3 T/F: You can’t string split on characters other than spaces. True False Only on tabs Only on newline s
You can pass a delimite r such as split("," ). O 3 4 You must convert string data into __ or __ to calculate. int/float list/tuple class/o bject bool/str A Numeri c convers ion allows arithme tic operati ons. O 3 5 Which string testing method tells you if input contains letters and/or numbers only, not .isalnum( ) .isalpha( ) .isdigit( ) .isspace ()
.isalnu m() is true for letters and digits only.
rec t Ratio nale even spaces? O 3 6 Which string testing method tells you if input contains just letters? .isalnum( ) .isalpha( ) .isdigit( ) .isspace ()
.isalpha () checks alphabe tic charact ers only. O 3 7 Which string testing method tells you if input contains just spaces? .isalnum( ) .isalpha( ) .isdigit( ) .isspace ()
.isspace () checks whitesp ace- only strings. O 3 8 Which string testing method tells you if input contains just numbers? .isalnum( ) .isalpha( ) .isdigit( ) .isspace ()
.isdigit() checks digit- only strings.
rec t Ratio nale O 4 3
.startswith and .endswith are case sensitive. True False Only startsw ith Only endswit h
Case matters unless the string is normali zed. O 4 4 T/F: When you do a replace, it will replace just the first instance. True False Only if count= 1 Only strings
str.repla ce() replace s all occurre nces by default. O 4 5 Making each sentence a list element is called ___. Sentence tokenizat ion Word tokenizat ion Data framin g Indexing A Sentenc e tokeniz ation splits text into sentenc es.
rec t Ratio nale O 4 6 Each word is a list element in ___. Word tokenizat ion Sentenc e tokenizat ion Slicing Data hiding
Word tokeniz ation splits text into words. O 4 7 A two- dimensional data structure like rows and columns, like a spreadsheet, is a ___. data frame string tuple class A
DataFra me has rows and column s. O 4 8 To read a spreadsheet file, we have to do what? Import pandas Import string Import rando m Import math
pandas provide s functio ns such as read_ex cel() and
rec t Ratio nale position beyond the end of the string, what will Python use instead? length as the effectiv e end. O 5 3 T/F: Indexing of a string starts at 1, so the index of the first character is 1, the index of the second character is 2, and so forth. True False Only in Python 2 Only for lists
Python indexin g starts at 0. O 5 4 Which method would you use to determine whether a certain substring is find(subs tring) append( substrin g) pop(su bstring ) delete(s ubstring )
find() returns the position or - 1 if not found.
rec t Ratio nale present in a string? O 5 5 What will be the value of the variable string after this code executes? string = 'abcd'; string = string.upper( ) 'Abcd' 'ABCD' 'abcd' Nothing ; this code is invalid
.upper() returns a new upperca se string. Section 2: Additional 100 Questions
Cor rect Ratio nale A What does len("MIS315") return? 5 6 7 Error B len() counts all characte rs, includin g digits.