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
BRAINLIEST FOR CORRECT ANSWERS PLS HELP
koban [17]
Either A or B. I would go with A but It can actually be B
5 0
3 years ago
Read 2 more answers
Which of the following can ensily reverse motion and are better at varying speeds than electrical motors?
harkovskaia [24]

Answer:

Where are the following? You have to post the full question if you want help.

Explanation:

7 0
3 years ago
Of the 5 factors that should be evaluated when assessing information's quality (Validity, Reliability, Accuracy, Timeliness, and
Art [367]
Validity is the best asseng information to evaluate the all factors
8 0
2 years ago
what's the best mouse for fast clicking ? I play a lot of fps and a lot of pvp games I need a mouse that I can click fast with a
kondaur [170]
Alenware hp dell logtech, and i know others
7 0
3 years ago
What is the MINIMUM number of paths that would need to be broken to prevent Computing Device A from connecting with Computing De
Sveta_85 [38]

Answer:

The answer is "Option c".

Explanation:

In the given question the device A is connected by 3 wires, contributing all of them, which also includes several connector paths. When all the wires of A are broken down, and if all of this leaves no routes that can be used. Even so, if it is done to E, it's also linked to four different routes. Its solution would've been C because its value will be the MINIMUM.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Write statementsto show how finding the length of a character array char [ ] differs from finding the length of a String object
    9·1 answer
  • Most keyboards today are in a
    8·1 answer
  • Which type of message format is designed to arouse curiosity, not showing the product or delivering quite enough information to
    10·1 answer
  • When using correct ergonomic technique be sure to
    6·2 answers
  • A third-grade teacher at Potter Elementary School wants a program that allows a student to enter the amount of money a customer
    14·1 answer
  • Which is the biggest known issue specific to satellite Internet connections?
    13·2 answers
  • When working with arrays, most programming languages perform ________, which means they do not allow programs to use invalid sub
    5·1 answer
  • Describe two different examples of potential conflicts, and explain why these conflicts can have a negative impact on
    14·1 answer
  • To have a reason or purpose to do something
    8·2 answers
  • What dog breed is this
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!