caitlynarowlett1197 caitlynarowlett1197
  • 20-01-2020
  • Computers and Technology
contestada

Create a function named first_a that uses a list comprehension. The function will take a single integer parameter n. Find every number from 1 to n (inclusive) that is a multiple of 6 or a multiple of 11. Do not use a helper function.

Respuesta :

ijeggs
ijeggs ijeggs
  • 23-01-2020

Answer:

def first_a(n):

   lst1 =[x for x in range(1,n+1)if x%6==0 or x%11 ==0]

   print(lst1)

Explanation:

Above is a function in python programming language. We have used list comprehension to check numbers that are multiples of 6 or 11 in a range.

When this function is called it will receive an argument (n) of type integer, a range will then be generated from 1 to n+1 since n is inclusive. The modulo operator is used to determine is a value is a multiple of 6 or 11, since their multiples will evaluate to 0

Answer Link

Otras preguntas

which group in Hawaii was in favor of annexation by the United states
Syntel Inc. has a stringent policy of analyzing the performance and working towards finding the cause and solution for performance. Which element of internal ac
According to the second law of thermodynamics, which is a requirement for thermal energy to flow from colder objects to hotter objects? A. Work must be done on
How many times do the graphs of y = 4x + 3 and y= -x2 – 1 intersect?
How did african americans express a new sense of hope and pride in the 1920's?
the perimeter of a rectangular painting is 298 centimeters. if the width of the painting is 53. centimeters, what is its length?
i need help solving 3x+14/4=2
Please help me. I don't know how I got 18000. Can someone please explain how to solve this problem?
Magnetic induction is used for what?
BILJUAERS: Terminar de trabajar a los 65 años