Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#Python Help please Modify the mistakes in my code , so that it prints the same statement four times. Using four distinct techniqueshard-coding, commas, concatenation,

#Python

Help please

Modify the mistakes in my code , so that it prints the same statement four times. Using four distinct techniqueshard-coding, commas, concatenation, and string formatting. The hard-coding is already done. The other three techniques have been started but they contain mistakes. These techniques should each use all three of the provided variables. Once the mistakes have been corrected, run the script and upload a picture of the program running to make sure that it prints the statement identically four times:

Found 12 lights in the 5 mi. buffer and 20 intersections.

Found 12 lights in the 5 mi. buffer and 20 intersections.

Found 12 lights in the 5 mi. buffer and 20 intersections.

Found 12 lights in the 5 mi. buffer and 20 intersections.

Correct the mistakes in this script so that it prints the same statement 4 times, using 4 different methods:

1) hard-coding

2) commas

3) concatenation

4) string formatting

Code:

trafficLightsCount = 12 bufferDist = '5 mi.' intersectionCount = 20

# 1) Entirely hard-coded statement. Don't change this one. # Make the other print statements match this output. print 'Found 12 lights in the 5 mi. buffer and 20 intersections.'

# 2) Modify the code to correctly use the three variables # and use commas to join expression components. print 'Found', trafficLightCount, lights in the intersectionCount buffer and, ' buffereDist' 'intersections.'

# 3) Modify the code to correctly use the three variables # and use concatenation to join expression components. print 'Found' + trafficLightCount + lights in the buffereDist buffer and intersectionCount intersections.'

# 4) Modify the code to correctly use ALL three variables # and use the string 'format' method. print 'Found {1} lights in the {0} buffer and 30 intersections.'format(trafficLightsCount, bufferDist)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

1. Outline the listening process and styles of listening

Answered: 1 week ago

Question

4. Explain key barriers to competent intercultural communication

Answered: 1 week ago