Display the stripped phone number

Assignment Help Python Programming
Reference no: EM132356510

Question

When people enter phone numbers, they typically enter it in a few different formats:

(919)866-5555

919-866-5555

9198665555

Write a program to strip all occurrences of these characters: '(', ')' and '-'. Also, strip all the leading and trailing whitespace characters. Display the stripped phone number. The following are a few examples:

Enter phone number: (919)866-5555

Phone number with extra characters stripped: 9198665555

Enter phone number: 919-866-5555

Phone number with extra characters stripped: 9198665555

Enter phone number: 9198665555

Phone number with extra characters stripped: 9198665555

[Hint: to delete a string, you can replace it by an empty string]

Save your Python program in a file named Lab13P1.py. Submit the file to Blackboard for credit.

Problem 2

All oranges sold in a grocery store have a 4-digit product code. If the rightmost digit is '4', the orange is from California. If the rightmost digit is '7', the orange is from Florida. For example, an orange with product code '8124' is from California. An orange with product code '6547' is from Florida. Write a program to do the following:

(a) Ask the user to enter the 4-digit code of an orange.

(b) Strip all the leading and trailing whitespace characters from the code.

(c) Test whether the code consists of only numeric digits. If it is not, display an error message.

(d) Test whether the code has exactly 4 characters. If it has more or fewer than 4 characters, display an error message.

(e) Test the rightmost digit. If it is '4', display 'This orange is from California'. If it is '7', display 'This orange is from Florida'. If it is something else, display 'The last digit must be 4 or 7'.

The following are three examples.

Enter product code: 12X45

Product code must consist of digits only.

Product code must not be longer or shorter than 4 characters.

The last digit must be 4 or 7

Enter product code: 0824

This orange is from California

Enter product code: 5237

This orange is from Florida

Save your Python program in a file named Lab13P2.py. Submit the file to Blackboard for credit.

Problem 3

Course codes in a community college consist of two parts: subject and course number. Subject must consist of 3 letters while course number must consist of 3 digits. For example, in the course code 'CIS115, subject is 'CIS', and course number is '115'. Write a program to do the following:

(a) Ask the user to enter a course code.

(b) Strip all the leading and trailing whitespace characters from the code. Display the stripped code.

(c) Test whether the course code is valid. If the course code does not follow the rules described above, display an error message. Otherwise, separate subject from course number and display them separately.

The following are four examples.

Enter course code: CIS115

Subject: CIS

Course number: 115

Enter course code: CIS1155

You have entered an invalid course code

Enter course code: CS2567

You have entered an invalid course code

Enter course code: CIS25K

You have entered an invalid course code

Reference no: EM132356510

Questions Cloud

Create a list called readinglist with two books : Define a function called printList that takes in a list as a parameter and prints the entries in the list one entry per line. If the list is empty have program.
Read a four digit decimal integer from the keyboard : Subject Use Python IDLE, select file menu then new file command to edit and debug your program. Write a complete Python program.
How many times each letter of the alphabet was used : Allow the user to type in a sentence to allow the program to perform analytics. Find out how many times each letter of the alphabet was used in useras sentence.
Analyze a comma-separated values file of real estate data : Write a menu driven console program that loads, parses and analyzes a comma-separated values file of real estate data.
Display the stripped phone number : Ask the user to enter the 4-digit code of an orange. Strip all the leading and trailing whitespace characters from the code. Display the stripped phone number.
Write a program to analyze the test scores : An instructor teaches two classes this semester. Recently he gave the same test to both classes. Write a program to analyze the test scores.
Display the array of names and the array of votes to provide : Write a function that accepts the name of an output file and displays the array of names and the array of votes to the provided output file.
Identify and describe one federal public health law : Key Participants in Decision Making - Identify and describe one federal public health law and the key decision makers in getting the law passed
Write a python program to list the data types used in this : Write a Python program to load the exact data into a data frame df2016. Write a Python program to list the data types used in this data frame.

Reviews

Write a Review

Python Programming Questions & Answers

  Print out the values of that loop using the print function

In Python, create a program that meets the following requirements: Print out the values of that loop using the Print function in Python.

  Write a python program for grocery list manager

Write a python program for grocery list manager and note taking system that has note taking mode and grocery listing mode.

  Allow the user to output all vehicle inventory to text file

Need an automobile class that will be used by a dealership as a vehicle inventory program. The following attributes should be present in your automobile class.

  Design and implementation of your demonstration system

ICT705 Data and System Integration Assignment Task, University of the Sunshine Coast, Australia. Design and implementation of your demonstration system

  What prompted the authors to try and address

What is the question that this study is trying to answer and what prompted the authors to try and address this question?

  Python errors

python errors, please correct them that are located in this program,

  Create a program that outputs reciept with tax

Created a program that outputs reciept with tax but cannot apply discount to 3 specific inputs. Only 3 inputs will have a discount all other inputs will have.

  Write a program that computes the circumference of a circle

Write a program that computes the circumference of a circle with a radius of 7.5 and prints out the result. The circumference is 2* pi * radius.

  Write a program that prompts the user for the numerator

Write a program that prompts the user for the numerator and denominator of an improper fraction, then displays the equivalent as a mixed number.

  Relation to the linear regression and the dataset

Build the in relation to the gradient boost tree and the dataset - Select a dataset (other than the example dataset given in section 3)

  Program using a loop that displays the projected semester

Write your program using a loop that displays the projected semester tuition for the next 7 years - You should then display the actual year

  Write a python class definition for class sumi

Write a python class definition for class ‘Sumi' with a single instance variable self.num of type ‘int' and single instance method called "sum_of_digits".

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd