100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
5.7.1 Strings Test Exam Answered Correctly!!! $11.99   Add to cart

Exam (elaborations)

5.7.1 Strings Test Exam Answered Correctly!!!

 1 view  0 purchase
  • Course
  • Strings
  • Institution
  • Strings

5.7.1 Strings Test Exam Answered Correctly!!!

Preview 2 out of 6  pages

  • September 30, 2024
  • 6
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Strings
  • Strings
avatar-seller
ElevatedExcellence
5.7.1 Strings Test Exam Answered
Correctly!!!
Which of the following expressions will result in "brown"?
Let sentence = "The brown lazy dog"

print(sentence[4:8])

print(sentence[4:9])

print(sentence[3:8])

print(sentence[3:9]) CORRECT ANSWERS print(sentence[4:9])

Which of the following expressions will print "dog"?
Let sentence = "lazy dog"

print(sentence[6:])

print(sentence[:])

print(sentence[:5])

print(sentence[5:]) CORRECT ANSWERS print(sentence[5:])

Which of the following expressions will print "L"?
Let word = "PINEAPPLE"

print(word[-4:])

print(word[-1])

print(word[-2])

print(word[-3]) CORRECT ANSWERS print(word[-2])

Which of the following string operation is illegal? Assume that word = "music".

word[0] = "M"

word = word[2] + word[-1]

word = "musical"

, word = word + "al" CORRECT ANSWERS word[0] = "M"

Which of the following expressions will get the last character in a string? Assume that
word is a string variable.
I. word[0]
II. word[-1]
III. word[len(word)]
IV. word[len(word)-1] CORRECT ANSWERS II, IV

What is the output of the following program?
sentence = "the dog"
for letter in sentence:
print(letter + letter) CORRECT ANSWERS tt
hh
ee
dd
oo
gg

Which of the following if statements checks if the string variable sentence contains the
word "the"?

if "t" or "h" or "e" in sentence:
print("Contains 'the'")

if "the" in sentence:
print("Contains 'the'")

if "the" == sentence:
print("Contains 'the'")

if sentence in "the":
print("Contains 'the'") CORRECT ANSWERS if "the" in sentence:
print("Contains 'the'")

Which of the functions below will return a string that is in alternating caps? For example,
alt_case("sheep") should return "sHeEp".

def alt_case(word):
res = ""
for i in range(len(word)):
if i % 2 == 1:
res + word[i].upper()
else:
res + word[i].lower()
return res

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller ElevatedExcellence. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $11.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

78462 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$11.99
  • (0)
  Add to cart