Menu

[solved]-1 String Called Quote Contains One Greatest Movie Quotes Time Want Convert Lowercase Lette Q39043381

1)We have a string called quote which contains one of thegreatest movie quotes of all time. We want to convert it into alllowercase letters and then into all uppercase letters.

When you are finished, your output will match the DesiredOutput.

# Create my_string
quote = “Hello, my name is Inigo Montoya”

# Display string in lowercase

# Display string in uppercase

deired output:

hello, my name is inigo montoyaHELLO, MY NAME IS INIGO MONTOYA

2)

We have a string called quote which contains one of the greatestmovie quotes of all time. We’re going to mess with this string.

  1. Check whether quote begins with the string “Hi” – display theresults.
  2. Check whether quote ends with the string “ya” – display theresults.
  3. Find the index of the substring “go” – display the results
  4. Replace all instances of the letter “o” with the letter “a” -display the results.

# Create my_string
quote = “Hello, my name is Inigo Montoya”

# Step 1: Display whether /quote/ starts with
# the word “Hi”

# Step 2: Display whether /quote/ ends with
# the word “ya”

# Step 3: Display the index of the word
# “go” within /quote/

# Step 4: Replace all instances of the
# letter “o” with the letter “a” in
# /quote/

desired output:

FalseTrue21Hella, my name is Iniga Mantaya

3)Split the string quote into individual words using the split()method, then print the result. When you are finished, your outputwill match the output under Desired Output.

# Create my_string
quote = “Hello, my name is Inigo Montoya”

# Step 1: Split /quote/ into individual words

# Step 2: Print the results

desired output:

[‘Hello,’, ‘my’, ‘name’, ‘is’, ‘Inigo’, ‘Montoya’]

4)

This is a portion of a program which gets the user’s age andchecks it to see if they are eligible to vote. In the past, wewouldjust convert the user’s input to an integer (or float), but if theuser entered something that wasn’t a number, the whole programwould stop with an error. To make this more user friendly, we aregoing to use a try/except statement when we convert the input to anumber.

  1. Add a try/except statement where you convert age to an integerusing int().
  2. Run the program and, when prompted, enter a non-numerical valueso your output matches the output under DesiredOutput.

# Set the variable
age = input(“What is your age?”)

# Insert a try/except statement here
# Your except statement should print the
# message /Please enter a valid age!/
age = int(age)
if age >= 18:
print(“Go vote!”)

desired output:

Please enter a valid age!

Expert Answer


Answer to 1)We have a string called quote which contains one of the greatest movie quotes of all time. We want to convert it into … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *