logo

Crowdly

Define and test a function myRange . This function should behave like Python’s...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Define and test a function myRange. This function should behave like Python’s standard range function, with the required and optional arguments, but it 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.)

Test your code with the following examples and ensure you get the same results:

print(myRange(5))          

 [0, 1, 2, 3, 4]

print(myRange(2, 5))      

[2, 3, 4]

print(myRange(2, 10, 3)) 

[2, 5, 8]

print(myRange(5, 2, -1))   

 [5, 4, 3]

print(myRange(5, 2, 1))    

[]

More questions like this

Want instant access to all verified answers on elearn.squ.edu.om?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!