Respuesta :
Answer:
Following are the program in the Python Programming Language:
def check_nums(length): #define function
my_lst=[] #set list type variable
n=0 #set integer type variable
while(length[n] != 7): #set the while loop
my_lst.append(length[n]) #append liat in my_lst
n+=1 #increament in n
if(len(length)==n): #set if condition
break #break the loop
return my_lst #return the list
l=[4,6,2,55,16,7,81] #set list variable and assign list init
print(check_nums(l)) #call and print the function
Output:
[4, 6, 2, 55, 16]
Explanation:
Here, we define a function "check_nums()" and pass an argument in its parentheses inside the function,
- we set list data type variable "my_lst" and integer type variable "n"
- we set while loop and pass the condition is the variable "length[n]" is not equal to the 7 then, the value of "length[n] " is appends to the variable "my_lst" and increment in the variable "n" by 1.
- we set if condition and check when the length of the variable "length" is equal to the variable "n" then, break the loop and return the value of "my_lst".
Finally, set the list type variable "l" and assign the list of numeric value in it then, call and print the function "check_nums"
In this exercise, using the knowledge of computational language in python, we have that this code will be written as:
The code is in the attached image.
We can write the python as:
def check_nums(length):
my_lst=[]
n=0
while(length[n] != 7):
my_lst.append(length[n])
n+=1
if(len(length)==n):
break
return my_lst
l=[4,6,2,55,16,7,81]
print(check_nums(l))
See more about python at brainly.com/question/13437928
