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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:00
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen tool
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
How is the number 372 written when expanded out to place values in the base 8 (octal) number system? a. 2 x 4 + 3 x 2 + 4 x 1 b. 3 x 64 + 7 x 8 + 2 x 1 c. 3 x 8 + 7 x 7 + 2 x 6 d. 3 x 100 + 7 x 10 + 2 x 1
Answers: 1
question
Computers and Technology, 22.06.2019 22:40
Write a program that defines symbolic names for several string literals (chars between quotes). * use each symbolic name in a variable definition. * use of symbolic to compose the assembly code instruction set can perform vara = (vara - varb) + (varc - vard); ensure that variable is in unsigned integer data type. * you should also further enhance your symbolic logic block to to perform expression by introducing addition substitution rule. vara = (vara+varb) - (varc+vard). required: debug the disassembly code and note down the address and memory information.
Answers: 3
question
Computers and Technology, 23.06.2019 01:30
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 2
You know the right answer?
The transform_comments function converts comments in a Python script into those usable by a C compil...
Questions
question
English, 11.06.2021 20:40
question
Mathematics, 11.06.2021 20:50
question
Mathematics, 11.06.2021 20:50
question
Mathematics, 11.06.2021 20:50
Questions on the website: 13722360