Define and test a function myRange. This function should behave like Python’s standard range function, with the required and optional arguments, but should return a list.Do not use the range function in your implementation!

Hints:

Study Python’s help on range to determine the names, positions, and what to do with your function’s parameters.
Use a default value of None for the two optional parameters. If these parameters both equal None, then the function has been called with just the stop value. If just the third parameter equals None, then the function has been called with a start value as well. Thus, the first part of the function’s code establishes what the values of the parameters are or should be. The rest of the code uses those values to build a list by counting up or down.

Answers

Answer 1
Answer:

The python program will be:

def myRange(start, stop = None, step = None):  

  if(step == None and stop == None):

        stop = start

        start = 0

        step = 1

    elif(step == None):

        step = 1

    result = []     if (step < 0):

        while stop < start:

            result.append(start)

            start += step     else:

        while start < stop:

            result.append(start)

            start += step     return result   def main():

    print([x for x in myRange(10)])

    print([x for x in myRange(1,10)])

    print([x for x in myRange(1, 10,2)])

    print([x for x in myRange(10, 1, -1)])

 main()

What do you mean by python?

Python is a high-level and general-purpose programming language. Its design idea prioritises code readability through the use of extensive indentation. It is compatible with a variety of programming paradigms, including structured, object-oriented, and functional programming. Because of its extensive standard library, it is frequently referred to as a "batteries included" language. Guido van Rossum began developing Python as a replacement to the ABC programming language in the late 1980s, and it was originally released in 1991 as Python 0.9.0. Python 2.0, which was launched in 2000, added new features including such list comprehensions, cycle-detecting garbage collection, reference counting.

To learn more about python
brainly.com/question/26497128

#SPJ2

Answer 2
Answer:

Answer:

Study Python’s help on range to determine the names, positions, and what to do with your function’s parameters.

Use a default value of None for the two optional parameters. If these parameters both equal None, then the function has been called with just the stop value. If just the third parameter equals None, then the function has been called with a start value as well. Thus, the first part of the function’s code establishes what the values of the parameters are or should be. The rest of the code uses those values to build a list by counting up or down.


Related Questions

The plow is to the agricultural system as the _________ is to the industrial society. steam enginedomestication of plants and animalscomputer chipunmapping of the DNA molecule
Select the correct answer.Brian wants to add a chart to his DTP project. What is the best way he can do this?A. draw the chart using the DTP program draw optionB.create the chart in a spreadsheet then import itC.use the DTP chart wizard to create the chart within the DTPD.create an image of the chart in an image editor then import the imageE.use HTML code to create a chart within the DTP program
This man is using a power saw.what do you think he is making?what simple machine is it
Find the error in the following pseudocode. Module main () Call raiseToPower (2, 1.5) End Module Module raiseToPower (Real value, Integer power) Declare Real result Set result=value^power Display result End Module
a security system uses sensors at every door and window which will set off an alarm if any one of them is opened. there is also a keypad by an entry door to turn on or turn off the system. describe how these components can be wired in a combination circuit to provide the needed security.

How can you tell that a website is valid and reliable

Answers

- suffix of site 
.edu = educational
.com = commercial
.mil = military
.gov = government
.org = nonprofit 
- also, if there is a listed author and they provide credentials 

To communicate with coworkers in the office

Answers

For effective communication to occur, everyone must trust and respect each other. ... Clear and concise communication will allow your colleagues to understand and then trust you. As a result, there will be more cooperation and less conflict in the workplace.

What is 25% of 60????????​

Answers

Answer:

15

Explanation:

The answer is 3 kind sir

If a line is 4’ and you scaled it using 1/8” =1’ what would the size of the line be?

Answers

One half inch to scale

10 facts about turbines

Answers

they provide wind energy
 Wind power consists of turning energy from the wind to other energy forms.
Windmills have been in use since 2000 B.C.
developed in Persia
Wind energy is the fastest growing mode of electricity
Wind farms can be constructed in off shore locations
Wind energy is renewable and pollution free source of energy
Most of the modern wind turbines have 3 blades
The largest wind turbine in the world is located in US in Hawaii
The first modern wind turbine was built in 1940’s in Vermont.
The provide wind power to lots of people

Why are x-ray and gamma-ray telescopes in space?

Answers

To observe ultraviolet, x-rays, gamma-rays or infrared, astronomers have had to put telescopes outside of Earth's atmosphere, normally in orbit around the Earth.