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]
2 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]2 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
What do you think of the extensive use of the non-diegetic sound in Return of the Jedi (1983)?
Jobisdone [24]

FOR ANYONE THAT WANTS TO STUDY AND CHILL SCREENSHOT BEFORE KATLE DELEATES THIS

meeting id:  932-8097-2909

password:  z99LtX

Explanation:

4 0
3 years ago
Search the link <br><br> gKuJXd3zYDc<br><br> Subscribe I have a vid premiering soon
lawyer [7]
I will hope this helps :p
5 0
3 years ago
Read the excerpt below and answer the question.
zysi [14]

Answer:

Agreed

Explanation:

8 0
3 years ago
A server needs to connect directly to the Internet. The ipconfig/all command shows that the server has been auto-assigned the IP
Deffense [45]

Answer:

Link-local address

Explanation:

IP addresses that have "FE80" as the hexadecimal representation of their first 10 bits are IPV6 reserved addresses for link-local unicast addressing. These addresses are automatically configured (though may be manually configured too) on any interface and should not be routed. They are used for addressing on a single link with the main aim, among others, of automatic configuration and routing protocol advertisement. Devices attached to this link can be accessed or reached using the link-local addresses as they don't need a global address to communicate.

However, routers will not forward datagram or packets using link-local addresses. In other words, routers are not allowed to connect to the internet using the unicast link-local addresses.

8 0
3 years ago
Louis has entered a column of expense values. What feature can he use to insert the total expenses at the end of the column?
vovangra [49]
I think it’s B tho I’m not really sure
5 0
3 years ago
Other questions:
  • Suppose a computer can execute 1 billion instructions/sec and that a system call takes 1000 instructions, including the trap and
    10·1 answer
  • How can i appear offline without fb messenger saying "last active 1 minute ago"?
    5·1 answer
  • Why are computer programs so much longer now than they were in the late 1980?
    8·1 answer
  • Mary is entering her senior year of college. She has a meeting on Friday with her advisor to discuss her career plans.Mary is al
    15·1 answer
  • Consider the following definition of the recursive function mystery. int mystery(int first, int last) { if (first &gt; last) ret
    12·1 answer
  • What is computer Network?​
    10·1 answer
  • Jason is working on a project that requires him to manage a huge amount of data. The spreadsheet he is working on has data relat
    10·1 answer
  • A two-dimensional array of characters can contain Group of answer choices
    11·1 answer
  • Which of the following actions can NEGATIVELY impact your credit score?
    9·1 answer
  • What is the MINIMUM number of paths that would need to be broken to prevent Computing Device A from connecting with Computing De
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!