89.0k views
5 votes
#Write a function called random_marks. random_marks should #take three parameters, all integers. It should return a #string. # #The first parameter represents how many apostrophes should #be in the string. The second parameter represents how many #quotation marks should be in the string. The third #parameter represents how many apostrophe-quotation mark #pairs should be in the string. # #For example, random_marks(3, 2, 3) would return this #string: #'''""'"'"'" # #Note that there are three apostrophes, then two quotation #marks, then three '" pairs. #Add your function here!

1 Answer

4 votes

Answer:

def random_marks(apostrophe, quotation, apostrophe_quotation):

return "'"*apostrophe + "\""*quotation + "'\""*apostrophe_quotation

print(random_marks(3, 2, 3))

Step-by-step explanation:

Create a function called random_marks that takes apostrophe, quotation, and apostrophe_quotation as parameters. Inside the function, return apostrophe sign times apostrophe plus quotation mark times quotation plus apostrophe sign quotation mark times apostrophe_quotation.

Note that plus sign (+) is used to concatenate strings. Also, if you multiply a string with a number, you get that number of strings ("#"*3 gives ###).

Then, call the function with given parameters and print

User Arany
by
5.5k points