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
pochemuha
3 years ago
12

Write a function named reverse_list that takes as a parameter a list and and reverses the order of the elements in that list. It

should not return anything - it should mutate the original list. This can be done trivially using slices, but your function must not use any slicing.
Computers and Technology
1 answer:
WITCHER [35]3 years ago
5 0

Answer:

The function in python is as follows:

def reverse_list(nums):

   half =int(len(nums)/2)

   for i in range(half):

       nums[i], nums[len(nums)-i-1] = nums[len(nums)-i-1],nums[i]

   print(nums)

Explanation:

This defines the function

def reverse_list(nums):

This gets the half the length of the list

   half =int(len(nums)/2)

This iterates through the list

   for i in range(half):

This swaps list items with the opposite item on the other half

       nums[i], nums[len(nums)-i-1] = nums[len(nums)-i-1],nums[i]

This prints the new list

   print(nums)

You might be interested in
Given an array of n distinct integers,d = [d[0], d[1],.., d[n - 1]], and an integer threshold, t, how many (a,b,c) index triplet
Setler79 [48]
I have a lot to say do not have to do this for the mnoth was the first day I was able to open and sign the new JTI documents and sign electronically sign up for additional support and electronically sign up for additional support and electronically sign documents electronically electronically sign the signature documents electronically sign up
4 0
3 years ago
Consider the following code snippet: int count = 0; int[][] numarray = new int[2][3]; for (int i = 0; i < 3; i++) { for (int
inna [77]
I have never seen this in my life sorry
7 0
3 years ago
The process where the programmer steps through each of the program's statements one by one is called
viva [34]

The process where the programmer steps through each of the program's statements one by one is called \sf\purple{hand \:tracing}.

\bold{ \green{ \star{ \orange{Mystique35}}}}⋆

5 0
3 years ago
Which of the following statements is true? A. Interpreted programs run faster than compiled programs. B. Compilers translate hig
alina1380 [7]

Answer:

B.

Explanation:

Computer programs are written in high level languages. Every language has its own set of syntax and semantics.

Computer only understands instructions in machine language which is written using strings of 0 and 1.

Thus, for execution of a high level language program, it is mandatory to convert high level instructions into machine instructions.

This translation into machine language is done in two ways – compilation or interpretation.

Some languages are compiled while others are interpreted.

Both compilers and interpreters are programs and process the high level language program as needed.

Compiler

Any program written in high level language is compiled.

The program is first analyzed before compilation. This process takes time. The analysis phase is called pre processing.

The program compilation stops only when the program is completely analyzed. Hence, it is difficult to locate the error in the program. This makes debugging easy.

Debugging is defined as removal of errors in the programs.

A compiler is responsible for converting high level language code into machine level code.

The complete program undergoes compilation at the same time.

A compiled program executes faster than an interpreted program.

A compiled program produce machine code which is a collection of 0 and 1, hence, it takes less time to execute.

Examples of compiled languages are C and C++.

Interpreter

Some high level languages are interpreted.

The high level language code is translated into an intermediate level code. This intermediate code is then executed.

The analysis of the program takes less time and takes place before interpretation begins. The analysis phase is called pre processing.

An interpreted program is translated one line at a time.

The program interpretation stops when an error is encountered. This makes debugging easy.

Debugging is defined as removal of errors in the programs.

Examples of interpreted languages include Python and Ruby.

6 0
4 years ago
Read 2 more answers
Is L.A. film school a private school?
Fudgin [204]
Is a private institution
6 0
4 years ago
Read 2 more answers
Other questions:
  • Which passage form the passage best contributes to elisa impatient tone
    8·1 answer
  • Which hardware device should he consider upgrading in order to increase the system's storage space?
    6·1 answer
  • Write a method isSorted that returns true if the list is in sorted (nondecreasing) order and returns false otherwise. An empty l
    12·1 answer
  • How can the storage model assist in the design of storage networks?
    12·1 answer
  • Ted is looking for a reliable source for his paper. Which of the following sites would be considered reliable?
    5·1 answer
  • A firm has a huge amount of individual customer data saved in different databases. Which of the following can be used to integra
    11·1 answer
  • I'm trying the game WWE 2k20 for my computers and technology and a extra credit question is how do you pull down the singlet str
    12·1 answer
  • Imagine that a crime has been committed and being a police officer you have to investigate the case. Solving a crime can be a ve
    12·1 answer
  • See the answerWrite a setInterval() function that increases the count by 1 and displays the new count in counterElement every 30
    11·1 answer
  • Where do charts get the data series names?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!