Exercise 1: Take the following Python code that stores a string:‘str = ’X-DSPAM-Confidence:0.8475’Usefindand string slicing to extract the portion of the string after the coloncharacter and then use...

1 answer below »
Exercise 1: Take the following Python code that stores a string:‘str = ’X-DSPAM-Confidence:0.8475’Usefindand string slicing to extract the portion of the string after the coloncharacter and then use thefloatfunction to convert the extracted string into afloating point number.Exercise 2:Read the documentation of the string methods athttps://docs.python.org/3.5/library/stdtypes.html#string-methodsYou might want to experiment with some of them to make sure you understandhow they work.stripandreplaceare particularly useful.The documentation uses a syntax that might be confusing. For example, infind(sub[, start[, end]], the brackets indicate optional arguments. Sosubis required, butstartis optional, and if you includestart, thenendis optional.
Answered 2 days AfterApr 12, 2021

Answer To: Exercise 1: Take the following Python code that stores a string:‘str =...

Aditya answered on Apr 14 2021
159 Votes
str = "X - DSPAM - Confidence: 0.8475"
list = str.split(':')
strnumber = list[1].strip()
number =
float(strnumber)
print('Number: ',number)
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here