Chapter 8 - Review

Ace your homework & exams now with Quizwiz!

What does the following code display? s = 'randomness' + 'is' + 'fun' print(s[1]+s[10]+s[13])

aiu

What does the following code display? mystring = 'abcdefg' print(mystring[2:5])

cde

This string method returns a copy of the string with all leading white-space characters removed. A. lstrip B. rstrip C. remove D. strip_leading

A. lstrip

This string method returns true if a string contains only alphabetic characters and is at least one character in length. A. the isalpha method B. the alpha method C. the alphabetic method D. the isletters method

A. the isalpha method

What does the following code display? letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' print(letters[0:10:3])

ADGJ

What does the following code display? s = 'Alice and Bob' s = s.upper() s = s[6:] print(s)

AND BOB

In python, strings are ____. A. Mutable B. Immutable C. Mandatory D. Eliminated

B. Immutable

This string method returns a copy of the string with all leading and trailing white-space characters removed. A. clean B. strip C. remove-whitespace D. rstrip

B. strip

This string method returns true if a string contains only numeric digits and is at least one character in length. A. the digit method B. the isdigit method C. the numeric method D. the isnumber method

B. the isdigit method

This is the first index in a string. A. -1 B. 1 C. 0 D. The size of the string minus one

C. 0

This function returns the length of a string. A. length B. size C. len D. lengthof

C. len

This string method returns a copy of a string with all the alphabetic letters converted to uppercase. A. uppercase( ) B. case_upper( ) C. upper( ) D. to_upperCase( )

C. upper( )

This is the last index in a string. A. 1 B. 99 C. 0 D. The size of the string minus one

D. The size of the string minus one

This operator determines whether one string is contained inside another string. A. contains B. is_in C. == D. in

D. in

(T/F) The isupper method converts a string to all uppercase characters

False

The statement print('QWERTY' * 2) will print _____ on the screen. A. QWERTYQWERTY B. QWERTY C. QW D. ERTY

A. QWERTYQWERTY

What does the following code display? name = 'joe' print(name.lower()) print(name.upper()) print(name)

joe JOE joe


Related study sets

The Logic of American Politics: Chapter 13 Quiz

View Set

Chapter 38: Corporations - Formation and Financing

View Set

Algebra Unit 0 & 1 Semester 1 Exam Review Solving Equations and Inequalities

View Set

8.1 The Structure of Financial Markets and Financial Assets

View Set

Supply and Demand: Theory: End of Chapter

View Set