Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please I need desperate help!!!! Part 3 - string methods In this section we'll experiment with a few string methods. 1. Write an expression to

Please I need desperate help!!!! image text in transcribed

Part 3 - string methods In this section we'll experiment with a few string methods. 1. Write an expression to search for the first occurrence of a substring in your name (pick any substring that is actually present in your name). This result must be expressed as an integer (i.e. save value in a variable named Index). 2. Use the rindex() method to find the position of the final space character in your full name. Use this method to find the position of that substring in your name, and save this value in the variable final_space. 3. Using the variable you saved in the previous step, write an expression to extract and print the last part of your name (The last part of my name is...) 4. Using the variable you saved in the second step, write an expression or statement to extract and print the first part of your name (The first part of my name is...). 5. Starting with your full_name variable above, write the code to create a new string in which all of the vowels ('a', 'e', 'i', 'o', and 'u') have been replaced with a dash ("-") character. You may need to write more than one line of code and create several new variables of your choice to do this. Be sure your code does not change your original variable, it should still contain your full name, unmodified. In the lab, we will see how to do this in 1 step. 6. Using your original full_name variable, write a single statement or expression that will display your name with a lower- case character at the beginning, and all of the rest of the characters in upper case. For example, if your full_name is 'Lisa Smith', this expression should print 'IISA SMITH'. Hint: You can start by creating several expressions (lines) and then try to combine in one statement. 7. It is very common to write programs to process text from the Internet, such as email or web pages. Many email formats include a standard header line that looks like this: header = 'From jsmith@gmail.com Wed Feb 03 9:32:39 2021 ' Write an expression to extract the domain name (in this case, 'gmail.com') from a string of this format. Your expression should work with most, or even all, strings formatted like this. Hint: This string lies between the first and only '@' and the second space character in the line. Part 3 - string methods In this section we'll experiment with a few string methods. 1. Write an expression to search for the first occurrence of a substring in your name (pick any substring that is actually present in your name). This result must be expressed as an integer (i.e. save value in a variable named Index). 2. Use the rindex() method to find the position of the final space character in your full name. Use this method to find the position of that substring in your name, and save this value in the variable final_space. 3. Using the variable you saved in the previous step, write an expression to extract and print the last part of your name (The last part of my name is...) 4. Using the variable you saved in the second step, write an expression or statement to extract and print the first part of your name (The first part of my name is...). 5. Starting with your full_name variable above, write the code to create a new string in which all of the vowels ('a', 'e', 'i', 'o', and 'u') have been replaced with a dash ("-") character. You may need to write more than one line of code and create several new variables of your choice to do this. Be sure your code does not change your original variable, it should still contain your full name, unmodified. In the lab, we will see how to do this in 1 step. 6. Using your original full_name variable, write a single statement or expression that will display your name with a lower- case character at the beginning, and all of the rest of the characters in upper case. For example, if your full_name is 'Lisa Smith', this expression should print 'IISA SMITH'. Hint: You can start by creating several expressions (lines) and then try to combine in one statement. 7. It is very common to write programs to process text from the Internet, such as email or web pages. Many email formats include a standard header line that looks like this: header = 'From jsmith@gmail.com Wed Feb 03 9:32:39 2021 ' Write an expression to extract the domain name (in this case, 'gmail.com') from a string of this format. Your expression should work with most, or even all, strings formatted like this. Hint: This string lies between the first and only '@' and the second space character in the line

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions