1. tmp = "Good Day";  print( tmp[2:4])     tmp = "John Doe"; print( tmp[5: ] ) Exact Output: 2.  sentence = "Hi Bye"      tmp = list(sentence); print(tmp) Exact Output: 3.Use a string method to PRINT True if a string cost contains only numbers.   Use a string method to PRINT True if a string name contains only letters.   Use a string method to PRINT True if a string tmp contains only numbers or letters.   Use a string method to PRINT True if a string tmp contains only whitespace.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

                       This is a python programming class

1. tmp = "Good Day";  print( tmp[2:4])

    tmp = "John Doe"; print( tmp[5: ] )

Exact Output:

2.  sentence = "Hi Bye"

     tmp = list(sentence); print(tmp)

Exact Output:

3.Use a string method to PRINT True if a string cost contains only numbers.

 

Use a string method to PRINT True if a string name contains only letters.

 

Use a string method to PRINT True if a string tmp contains only numbers or letters.

 

Use a string method to PRINT True if a string tmp contains only whitespace.

 

 

 

4. Use a string method to PRINT how many times the letter 'e' appears in a string called sentence

print(                                                                           )

5. Use a string method to PRINT the number of characters in a string tmp

 

print(                                                                           )

6. Use a string method to PRINT the location of the LAST period in a string tmp

 

Use a string method to PRINT the location of the FIRST period in a string tmp

print(                                                                           )

 

 

print(                                                                           )

7. Use a string method to change all of the periods in tmp to commas

print(                                                                           )

8. Use a string method to print True if a string url has the word 'edu' at the end

 

Use a string method to print True if a string phone has the area code '218'

 

9. Use a string method to get rid of all leading and trailing spaces in a string tmp

 

10. sentence = "Hi Bye";

tmp = sentence.split(" "); print(tmp)

sentence = "hello!"

tmp = sentence.split(" "); print(tmp)

Exact Output:

11.

stuNames = ("John", "Peter", "Vicky")

x = "#".join(myTuple)

print(x)

 

phEls=['218','477','2339'];phoneNum="-"

phoneNum.join(phEls); print(phoneNum)

 

myList = ['a','e','i','o','u']; print("".join(myList))

Exact Output:

 

 

Short Coding:

1. For a name which will always begin with Mr. or Mrs., or Ms., use a PYTHON string method to determine if the person is male or female.

 

2. For an email address use a PYTHON string method to PRINT "education" if it is an educational site (.edu) , "government" if it is a government site (.gov), "business" if it is a business (.com), or a "Non-Profit" if it is a non-profit (.org). 

 

 

3. Suppose tmp contains a string that indicates cost of an item, and it contains a leading $ and may contain commas and one period. Example: tmp = "$5,234.

Write Python code to remove the dollar sign and comma from tmp, change it to a number and double it.

 

 

 

 

4. Write Python to print the number of vowels in a sentence entered by the user.

 

 

 

 

 

5. Write function called myFind which accepts a 2 strings as parameters (tmp and strToFind) and returns the location of the first occurrence of strToFind in tmp . You may NOT use Python's built-in find OR rfind OR index functions.

 

 

 

 

 

6. Write function called myIsDigit which accepts a single parameter (a string) and returns True if every character in the string is a digit and False otherwise. You may NOT use Python's isdigit method.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY