Select Page

Question 5:1*1=11*2=2 2*2=41*3=3 2*3=6 3*3=91*4=4 2*4=8 3*4=12 4*4=161*5=5 2*5=10 3*5=15 4*5=20 5*5=25After the match, we want to compute damage values of different characters. To speed up the calculation process, we decided to create a multiplication table.1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=361*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=491*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=641*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81We will approach this problem in two steps:Question 5.1:Write a function that generates asingle row of the above multiplication table based on the number passed in and returns it as a string. For instance, if I pass in 9, the function should generate and return the string:”1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81″You can assume that the number passed in is a positive integerYouMUST solve this question withlist comprehension. Your implementation should only return an expression. In other words, without the 79-character line length limit, your implementation should fit in exactly one line.No explicit loops (for loop or while loop) are allowed. DoNOT add any inline comments.There are examples of correct syntax at the top of the writeup.Hint:str.join() may be useful here. For instance, “n”.join([‘a’, ‘b’, ‘c’]) will return “anbncn”, which when printed out, looks like:abcYou can use this in order to combine different rows together.Another way we can use str.join() is with an empty space. So ” “.join([‘a’, ‘b’, ‘c’]) gives us “a b c”.Hint:For this question, you can utilize thestr.format() method in order to help you generate each of the equations. Here are a couple of examples to show you how to use it:txt1 =”My name is {char_name}, I’m {age}”.format(char_name =”Tracer”, age =40)txt2 =”My name is {0}, I’m {1}”.format(“Tracer”,40)txt3 =”My name is {}, I’m {}”.format(“Tracer”,40)defscore_line(num): “””IMPORTANT: You should only use list comprehension for this question.Follow the syntax guidelines in the writeup.>>> print(score_line(5))1*5=5 2*5=10 3*5=15 4*5=20 5*5=25>>> print(score_line(9))1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81>>> print(score_line(1))1*1=1″””Question 5.2:Now that we are able to generate a single row of the multiplication table, we want to be able to generate a full multiplication table with various rows with a single function call.Write a function that takes in a positive integernum_rows, and returns a string representing the multiplication table containing rows from numbers 1 tonum_rows (inclusive).YouMUST solve this question withlist comprehension. Your implementation should only return an expression. In other words, without the 79-character line length limit, your implementation should fit in exactly one line.No explicit loops (for loop or while loop) are allowed. DoNOT add any inline comments.There are examples of correct syntax at the top of the writeup.Hint:str.join() may be useful here. For instance, “n”.join([‘a’, ‘b’, ‘c’]) will return “anbncn”, which when printed out, looks like:abcYou can use this in order to combine different rows together.Hint: You can re-use the function from 5.1 in order to generate lines of the multiplication table or you can create a completely new one.defscore_table(num_rows): “””IMPORTANT: You should only use list comprehension for this question.Follow the syntax guidelines in the writeup.>>> print(score_table(9))1*1=11*2=2 2*2=41*3=3 2*3=6 3*3=91*4=4 2*4=8 3*4=12 4*4=161*5=5 2*5=10 3*5=15 4*5=20 5*5=251*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=361*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=491*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=641*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81>>> print(score_table(5))1*1=11*2=2 2*2=41*3=3 2*3=6 3*3=91*4=4 2*4=8 3*4=12 4*4=161*5=5 2*5=10 3*5=15 4*5=20 5*5=25>>> print(score_table(1))1*1=1″””Computer ScienceEngineering & TechnologyPython Programming DSC 20

Order your essay today and save 20% with the discount code ESSAYHELP