Simple Python! Determine if a caller should be answered or ignored. Prompt the user for the first digit of a telephone number and store in a variable as a string. Prompt the user for the second digit of a telephone number and store in a variable as a string. Prompt the user for the third digit of a telephone number and store in a variable as a string. Prompt the user for the fourth digit of a telephone number and store in a variable as a string. Using the if-else Decision Structure, if the following conditions are met, the caller should be ignored: The first digit is "8" or "9". The fourth digit is "8" or "9". The second and third digits are the same. Display a message stating whether the caller should be answered or ignored and the four digits. To receive full credit: Only one if-statement can be used. The Boolean condition in the one if-statement can use any combination of AND and OR operators to test for the three conditions.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Simple Python!

Determine if a caller should be answered or ignored.

  1. Prompt the user for the first digit of a telephone number and store in a variable as a string.
  2. Prompt the user for the second digit of a telephone number and store in a variable as a string.
  3. Prompt the user for the third digit of a telephone number and store in a variable as a string.
  4. Prompt the user for the fourth digit of a telephone number and store in a variable as a string.
  5. Using the if-else Decision Structure, if the following conditions are met, the caller should be ignored:
    1. The first digit is "8" or "9".
    2. The fourth digit is "8" or "9".
    3. The second and third digits are the same.
  6. Display a message stating whether the caller should be answered or ignored and the four digits.

To receive full credit:

  1. Only one if-statement can be used.
  2. The Boolean condition in the one if-statement can use any combination of AND and OR operators to test for the three conditions.
Expert Solution
Step 1: Program explanation

1) Below is python program to determine if a caller should be answered or ignored

  • It prompts the user for the first digit of the telephone number
  • Prompt the user for the second digit of the telephone number
  • Prompt the user for the third digit of the telephone number
  • Prompt the user for the fourth digit of the telephone number
  • Check if the caller should be ignored based on below scenerios
    • The first digit is "8" or "9".
    • The fourth digit is "8" or "9".
    • The second and third digits are the same.
    • Only one if condition is used with OR operation
  • Based on these condition it displays a message stating whether the caller should be answered or ignored and the four digits.

2) Save program in python file and run

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education