1. A – D, identify the errors and rewrite the statement in the correct syntax. Save your code as PE3_1.py. phoneNum print ("QCC phone number is " A = 718-710-4756 + phoneNum + '.') Debug В finally = "happily ever after." print("They lived " + finally) Debug C age = 20 print("I am + age + %3D %3D years old.") Debug D input ("Enter your age: ") age = print("Next year you will be (age+1)) %3D

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

nEEd help with python...please paste ur indented code here:

 

 

Sure! Here is a transcription of the text and explanations for educational purposes:

---

1. **A – D, identify the errors and rewrite the statement in the correct syntax. Save your code as PE3_1.py.**

|    | Code                                                                                              |
|----|---------------------------------------------------------------------------------------------------|
| A  | phoneNum = 718-710-4756                                                                           |
|    | print("QCC phone number is " + phoneNum + '.')                                                    |
| Debug:                                                                                                |
| B  | finally = "happily ever after."                                                                   |
|    | print("They lived " + finally)                                                                   |
| Debug:                                                                                                |
| C  | age = 20                                                                                          |
|    | print("I am " + age + " years old.")                                                             |
| Debug:                                                                                                |
| D  | age = input("Enter your age: ")                                                                   |
|    | print("Next year you will be " + (age+1))                                                        |
| Debug:                                                                                                |

**Explanation:**

Each part labeled A to D contains a small piece of code with errors that need fixing:

- **A:** 
  - Error: The phone number `718-710-4756` is a string containing hyphens, but it is treated as a number and not enclosed in quotes.
  - Fix: `phoneNum = "718-710-4756"`

- **B:** 
  - Error: `finally` is a reserved keyword in Python, so it cannot be used as a variable name.
  - Fix: Rename the variable, e.g., `ending = "happily ever after."`

- **C:** 
  - Error: The variable `age` is an integer, and it cannot be concatenated directly with strings.
  - Fix: Convert age to a string, e.g., `print("I am " + str(age) + " years old.")`

- **D:** 
  - Error: `input()` returns a string, so adding 1 to this string causes a type error.
  - Fix: Convert the `input` to an integer, e.g., `age = int(input("Enter your age: "))` and then `print("Next year you will be " + str(age+1))`

Each corrected code snippet should be saved in a Python file named `PE3_1.py`.
Transcribed Image Text:Sure! Here is a transcription of the text and explanations for educational purposes: --- 1. **A – D, identify the errors and rewrite the statement in the correct syntax. Save your code as PE3_1.py.** | | Code | |----|---------------------------------------------------------------------------------------------------| | A | phoneNum = 718-710-4756 | | | print("QCC phone number is " + phoneNum + '.') | | Debug: | | B | finally = "happily ever after." | | | print("They lived " + finally) | | Debug: | | C | age = 20 | | | print("I am " + age + " years old.") | | Debug: | | D | age = input("Enter your age: ") | | | print("Next year you will be " + (age+1)) | | Debug: | **Explanation:** Each part labeled A to D contains a small piece of code with errors that need fixing: - **A:** - Error: The phone number `718-710-4756` is a string containing hyphens, but it is treated as a number and not enclosed in quotes. - Fix: `phoneNum = "718-710-4756"` - **B:** - Error: `finally` is a reserved keyword in Python, so it cannot be used as a variable name. - Fix: Rename the variable, e.g., `ending = "happily ever after."` - **C:** - Error: The variable `age` is an integer, and it cannot be concatenated directly with strings. - Fix: Convert age to a string, e.g., `print("I am " + str(age) + " years old.")` - **D:** - Error: `input()` returns a string, so adding 1 to this string causes a type error. - Fix: Convert the `input` to an integer, e.g., `age = int(input("Enter your age: "))` and then `print("Next year you will be " + str(age+1))` Each corrected code snippet should be saved in a Python file named `PE3_1.py`.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

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