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
jenyasd209 [6]
3 years ago
10

Write the function powersOf3ToN(n) that takes a possibly-negative float or int n, and returns a list of the positive powers of 3

up to and including n. As an example, powersOf3ToN(10.5) returns [1, 3, 9]. If no such powers of 3 exist, you should return the empty list. You may not use loops/iteration in this problem.
Computers and Technology
1 answer:
Paha777 [63]3 years ago
4 0

Answer:

def powersOf3ToN(n):

   try:

       num = int(round(n))

   except (ValueError, NameError, TypeError):

       print("Parameter of the function must be integer or float")

       quit()

   num_list = range(num)

   val_list = [pow(3,x) for x in num_list if pow(3,x) in num_list]

   print(val_list)

powersOf3ToN(30)

Explanation:

The python code prints out a list of integer numbers that are equivalent to the power of three. The function accepts integer and floating numbers but not strings or it prints an error message and quits the program.

You might be interested in
Which routing protocol does an exterior router use to collect data to build its routing tables?
natita [175]

Answer:

D. BGP

Explanation:

In order to exchange routing information with another AS (Autonomous Systems) only, exterior routers use an exterior routing protocol, like BGP (Border Gateway Protocol) or EGP (Exterior Routing Protocol).

BGP is an application-layer protocol in the TCP/IP suite, that uses a well-known TCP port (179) in order to deliver information reliably.

It is important to note that in order to exchange routing data within his own AS, the router uses an interior routing protocol, like OSPF.

3 0
3 years ago
Which storage device is not recommended as a permanent storage solution?
Brut [27]

Answer:

In comparison to permanent storage, non-permanent storage, also called volatile memory, is a storage device whose data is lost when its power source is disconnected. Examples of non-permanent storage include CPU cache and RAM.

Explanation:

i just know

8 0
2 years ago
Write a program that continually prompts the user for an integer input until input is entered that is less than 0. Each input th
professor190 [17]

Answer:

Following are the program in the C++ Programming Language:

#include <iostream>//header file

using namespace std;//namespane

//set main method

int main() {  

int a[100]; //set integer type array variable

int value, i = 0; //set integer variables

cout<<"Enter less than 0 to exit:"<<endl; //message for exit

cout<<"Enter the integer numbers:"<<endl; //message to enter numbers

do{ //set do while

cin>>value; //get input from the user

a[i++] = value; //append elements in array

}while(value>=0);

i--;  

cout<<"\nArray are:"<<endl;//message for array

for(int k = 0;k<i;k++){ //set for loop

cout<<a[k]<<" "; //print array

}

return 0;

}

<u>Output</u>:

Enter less than 0 to exit:

Enter the integer numbers:

1

2

3

4

5

-1

Array are:

1 2 3 4 5

Explanation:

Here, we set the integer data type main method "main()" and inside it:

  • we set integer type array variable with index value 100.
  • we set two integer type variable "value" and "i" initialize value 0.
  • we set the do-while loop in which we get the input from the user and and append in the array and pass condition if the value is greater then equal to 0.
  • Finally, set for loop and print the elements of an array.

 

7 0
3 years ago
The method needed to arrange for an object to be notified when a window's close-window button has been clicked is
Readme [11.4K]
The correct answer that would best complete the given statement above would be the term addWindowListener. <span>The method needed to arrange for an object to be notified when a window's close-window button has been clicked is addWindowListener. Hope this is the answer that you are looking for. </span>
7 0
3 years ago
There are several reasons it’s important to use the right tool and the right size tool for the job, but the most important reaso
Helga [31]

Answer:

ok t dog

Explanation:

4 0
3 years ago
Other questions:
  • Question: Henry wants to change the configuration information of an application. Which file should Henry edit to change this inf
    15·1 answer
  • What is a bus master?
    14·1 answer
  • Correspondence involves verbal communication. True False
    6·2 answers
  • Fill in the blank.
    7·1 answer
  • What is a googleplex?
    7·1 answer
  • Which of the following BEST describes an extranet?
    13·1 answer
  • Anthony is responsible for tuning his organization's intrusion detection system. He notices that the system reports an intrusion
    8·1 answer
  • Drag the right word to it’s definition
    13·1 answer
  • Question # 5
    6·1 answer
  • In a PC, which of the following components stores the BIOS
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!