subject

The transform_comments function converts comments in a Python script into those usable by a C compiler. This means looking for text that begins with a hash mark (#) and replacing it with double slashes (/), which is the single-line comment indicator. For the purpose of this exercise, we'll ignore the possibility of a hash mark embedded inside of a Python command, and assume that it's only used to indicate a comment. We also want to treat repetitive hash marks (##), (###), etc., as a single comment indicator, to be replaced with just (//) and not (#/) or (1/#). Fill in the parameters of the substitution method to complete this function: 4 1 import re 2 - def transform_comments (line_of_code): 3 result = re. sub (_) return result 5 6 print(transform_comments("### Start of program")) 7 # Should be "// Start of program" 8 print(transform_comments(" number = 0 ## Initialize the variable")) 9 # Should be number = 0 // Initialize the variable" 10 print(transform_comments(" number += 1 # Increment the variable")) 11 # Should be " number += 1 // Increment the variable" 12 print(transform_comments("return(nu mber)")) 13 # Should be return(number)" Run Reset

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 20.06.2019 18:04, theman300045
What is secondary exchange ? - apex a. returning a product you are unhappy with b. buying the same product more than once c. buying from people instead of companies d. recycling a previously recycled product
Answers: 2
image
Computers and Technology, 23.06.2019 09:00, 19youngr
Which company provides a crowdsourcing platform for corporate research and development? a: mtruk b: wiki answers c: mediawiki d: innocentive
Answers: 2
image
Computers and Technology, 23.06.2019 15:20, yeahmaneee
What does a bonus object do? a. subtracts lives b. keeps track of a player's health c. gives a player an advantage d. makes text appear
Answers: 1
image
Computers and Technology, 23.06.2019 21:20, nicki76
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
You know the right answer?
The transform_comments function converts comments in a Python script into those usable by a C compil...

Questions in other subjects:

Konu
Mathematics, 17.12.2020 22:00
Konu
Mathematics, 17.12.2020 22:00
Konu
Chemistry, 17.12.2020 22:00