1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
-Dominant- [34]
3 years ago
5

write a function deal3 of type 'a list -> a' list whose output list is the same as the input list, but with the third element

deleted.
Computers and Technology
1 answer:
qwelly [4]3 years ago
8 0

Answer:

I am writing a python program for this.  

  def deal3(input_list, index):  

   list = []    

   for x in range(len(input_list)):            

       if x != index:  

           list.append(input_list[x])  

   print('list ->',list)      

input_list = [10, 20, 30, 40, 50]  

index = 2

deal3(input_list, index)

Explanation:

  • The first line of code defines a function deal3 which has two parameters. input_list which is an input list and index is the position of elements in the input list.
  • next statement list=[] declares a new list that will be the output list.
  • next statement for x in range(len(input_list)):   is a loop which the loop variable x will traverse through the input list until the end of the input list is reached.
  • the next statement if x != index:  checks if x variable is equal to the position of the element in the list.
  • Next statement list.append(input_list[x]) appends the elements of input list to list( new list that will be the output list). Now the output list will contain all the elements of the input list except for the element in the specified position (index variable).
  • this statement print('list ->',list) prints the list (new output list).
  • this statement input_list = [10, 20, 30, 40, 50]  insert elements 10 20 30 40 50 in the input list.
  • index=2 specifies the second position (3rd element) in the list that is to be removed.
  • deal3(input_list, index) So the function is called which will remove 3rd element of the input list and prints output array with same elements as that in input array except for the element at the specified position.

You might be interested in
Implement a Python function with the signature Transfer(S, T) that transfers all elements from the ArrayStack instance S onto th
Mashutka [201]

Answer:

Following are the program in the Python Programming Language.

#define function

def Transfer(S, T):

 #set for loop  

 for i in range(len(S)):

   #append in the list

   T.append(S.pop())

 #return the value of the list

 return T

#set list type variable

S = ["a","b","c","d"]

#print the values of the list

print(S)

#set the list empty type variable

T=[]

#call the function

T = Transfer(S, T)

#print the value of T

print(T)

<u>Output:</u>

['a', 'b', 'c', 'd']

['d', 'c', 'b', 'a']

Explanation:

Here, we define the function "Transfer()" in which we pass two list type arguments "S" and "T".

  • Set the for loop to append the values in the list.
  • Then, we append the value of the variable "S" in the variable "T".
  • Return the value of the list variable "T" and close the function.
  • Then, set the list data type variable "S" and initialize the elements in it and print that variable.
  • Finally, we set the empty list type variable "T" and store the return value of the function "Transfer()" in the variable "T" then, print the value of the variable "T".
4 0
3 years ago
The data I collect in Google Forms are all compiled in a spreadsheet for me.<br> False <br> True
Mandarinka [93]
I think it's false. If I'm wrong then sorry.
5 0
3 years ago
Read 2 more answers
¿Qué creo que debe considerar una empresa para elegir ellugar en el cual va a desarrollar su actividad económica osu emprendimie
zhannawk [14.2K]

Answer:

sorry I don't speak that language

8 0
3 years ago
Match each of the following terms to its function:_________
Crazy boy [7]

Answer:

I = B

II = E

III = A

IV = D

V = C

7 0
3 years ago
Assume values 10, 20, 30, and 40 are entered in the cell range A1:A4. Cell A10 contains the formula: =A1+A2+A3+A4 and displays v
r-ruslan [8.4K]

Answer:

The formula and value to this question is "=A1+A3+A4+A5 with value 100"

Explanation:

The explanation of the given question as follows:

  • In question, it is defined that four cells that are "A1, A2, A3, and A4"  contains value that are "10, 20, 30, and 40".
  • To add these values we use addition formula that is "=A1+A2+A3+A4". it will give value 100.
  • If the user inserts a new row that is "A2" and assigns a value in the cell that is "50" so, we use the above formula that adds values with these values we also use the value "100".
8 0
3 years ago
Other questions:
  • Define the following term: - hue
    11·2 answers
  • Markup is best defined as
    11·1 answer
  • g If a class named Student has a data member named gpa , and one of its member functions has a parameter also named gpa , how ca
    7·1 answer
  • If you were to create a new app for a smartphone or tablet that does not already exist, what would you create?
    10·1 answer
  • Is anyone really good at immerse 2 learn??
    9·1 answer
  • Write a shell (text-based) program, called first_word.py, that opens the file stuff.txt and prints out the first word of every l
    14·1 answer
  • How to create an app on app store please its not a joke, if someone knows tell me how
    15·1 answer
  • Write a program that allows the user to enter their name from the keyboard. Allow the user to pick how many times they want thei
    12·1 answer
  • Generally speaking, what is a “best practice"?
    13·1 answer
  • MODERATOR DELETE MY ACC
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!