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
sukhopar [10]
3 years ago
13

Define and test a function myRange. This function should behave like Python’s standard range function, with the required and opt

ional arguments. 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.)
Computers and Technology
2 answers:
Reil [10]3 years ago
4 0

Answer:

YOU DONT HAVE A QUESTION ITS A LONG STATEMENT

Explanation:

Sloan [31]3 years ago
4 0

Answer:

#section 1

def ran(first, *last):

   li = []

#section 2

   try:

       if len(last) > 2:

           raise ValueError

       

       elif len(last) == 1:

           while last[0] > first:

               li.append(first)

               first = first + 1

           print(li)

       

       elif len(last) == 2:

           while last[0] > first:

               li.append(first)

               first = first + last[1]

           print(li)

           

           

       else:

           i=0

           

           while i < first:

               li.append(i)

               i= i + 1

           print(li)

                  

   except:

       print("Ran expected at most three arguments at most got", len(last)+1)

   

 

Explanation:

#section 1

The function is defined and a list is created to hold the range of values specified.

It is important to note that the function was created using one required argument and using by *args (*last), The function is allowed to accept extra positional arguments.

#section 2

In this section, we limit the extra positional arguments to two using a try and except block and raising a value error anytime a positional arguments more than three (remember we have 1 required argument) is entered.

The *args supply their arguments in a tuple.

Finally, within the try and except block depending on the arguments given; IF, ELIF and ELSE blocks are available to take those arguments and return the appropriate answer to generate the required range of values

You might be interested in
To print the last element in the array named ar, you can write :A. System.out.println(ar.length);
timofeeve [1]

Answer:

Option (d) is the correct answer.

Explanation:

An Array is used to store multiple variables in the memory in the continuous memory allocation on which starting index value is starting from 0 and the last index value location is size-1.

In java programming language the array.length is used to tells the size of the array so when the user wants to get the value of the last element, he needs to print the value of (array.length-1) location so the correct statement for the java programming language is to print the last element in the array named ar is--

System.out.println(ar[ar.length-1]);

No option provides the above statement, so option d (None of these) is correct while the reason behind the other option is not correct is as follows--

  • Option a will prints the size of the array.
  • Option b also gives the error because length is an undeclared variable.
  • Option c will give the error of array bound of an exception because it begs the value of the size+1 element of the array.
3 0
3 years ago
Write a program and flowchart. The program should ask the user for the average temperature in each of the last 12 months. After
Afina-wow [57]

#First we define the variables to house the temperatures

#temp is an empty array that will be used to store the temperature

Temp = []

#The months is defined as stated below

months = 12

#Ask the user for the temperature input and unit if possible

print("Kindly enter the temperature here")

#the program enter loop to get the temperatures.

for x in range(months):  

   InitTemp = str(input("Kindly add the unit behind the number .eg C for celcius"))

   Temp.append(InitTemp)

j=0

for x in range(len(Temp)):  

   j=j+1

   print("The Temperature is", " ", Temp[x], "for the ", j, "Month" )

#there is an attached photo for the flowchart

5 0
2 years ago
Which nation has a command economy
Over [174]

Answer:command economy is a key feature of any communist society. Cuba, North Korea, and the former Soviet Union are examples of countries that have command economies, while China maintained a command economy for decades before transitioning to a mixed economy that features both communistic and capitalistic elements

5 0
2 years ago
Read 2 more answers
Which feature of a word processing program enables you to represent any numerical data in the form of a diagram?
WARRIOR [948]
I think the answer to this is SmartArt. it helps you create any type of diagrams in either powerpoints or word. 
7 0
3 years ago
Read 2 more answers
A collection of a set of instrument that solve a problem is called .....​
Maru [420]

Answer:

Internet

Explanation:

A collection of a set of instrument that solve a problem is called the internet.

The Internet is an enormous networking infrastructure that uses the Internet protocol suite (TCP/IP). It connects millions of computers together globally, forming a network in which computers can communicate with each other provided that they are both connected to the Internet.

The Internet contains billions of web pages and resources created by software engineers from around the world, making it a limitless place to locate information and solve peculiar problems.

3 0
3 years ago
Read 2 more answers
Other questions:
  • When people need information, they typically turn to:
    7·1 answer
  • Write a Python function called validateCreditCard that takes 8-digit credit card number as the input parameter (string value) an
    8·1 answer
  • ____ port is a connection in which eight data lines transmit an entire byte of data at one moment in time.
    12·1 answer
  • Which of the following actions is an example of "window dressing?" a. Using some of the firm’s cash to reduce long-term debt. b.
    13·1 answer
  • what type of machine is a ramp for wheelchairs? compound machine, mechanical, machine complex machine, simple machine
    15·2 answers
  • Which is a basic job requirement for a career in corrections services?
    13·1 answer
  • Project: Math Tutor Program with Error Handling
    9·2 answers
  • Karen works in a department store. Her coworker gave diverse cultural backgrounds. Which statement shows that Karen understand t
    14·1 answer
  • Temperature converter. This program should prompt the user for two arguments, first a decimal number and second, a single letter
    10·1 answer
  • For some reason my code is not printing in python. It doesn't give me an error is just not printing no thing shows up
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!