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
Which device on a network performs network address translation?
Alika [10]
Network Address Translation<span> (NAT) is the answer</span>
4 0
3 years ago
Adam is so good at playing arcade games that he will win at every game he plays. One fine day as he was walking on the street, h
klio [65]

Answer:

what the answer chaoices

Explanation:

brainlest me please

3 0
2 years ago
Components of an operating system include process,memory,and file management. what is another component of and operating system
kirza4 [7]

Answer:

Wrong it's actually C.

Explanation:

APEX

4 0
2 years ago
Read 2 more answers
You've formatted the first paragraph of a document. What button can you use to apply the formatting from the first paragraph to
Nata [24]
I think the answer is B. format painter 

3 0
3 years ago
Did it go from a sail boat to a row boat or vise versea
Bingel [31]
A sail boat went to a row boat.
8 0
3 years ago
Other questions:
  • The operation of the waste spark Ignition system is being discussed. technician a says that the spark that occurs on the exhaust
    14·1 answer
  • Why was the movable type of the printing press such a breakthrough for publishing?
    15·2 answers
  • A(n ________ is a program that is used to create, process, and administer a collection of self-describing integrated records.
    14·1 answer
  • When you access the programs and documents on a computer by what way of icons is said to be employing
    6·1 answer
  • What fields of engineering are in Biomedical
    7·1 answer
  • What disese is sue suffering from
    15·2 answers
  • Consider the following sequence of page references: 1 2 3 3 4 4 1 4 1 3 4. Determine how many page faults will occur with LRU(Le
    13·1 answer
  • Which of the following statements describes the general idea of an assistive media​
    7·1 answer
  • What kind is a utility file that shrinks the size of a file
    14·1 answer
  • Because his father _____ his ten-speed bike away to punish him for his failing grades, the boy sulked for two days.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!