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
That's my email address​
rodikova [14]
Okay then that’s pretty cool
3 0
3 years ago
Impact of information technology in the society​
GarryVolchara [31]

Answer:

led to exposure of dangerous things

3 0
3 years ago
Jorge is looking for information about the life of his favorite music artist, Ray Charles. Which type of resource(s) would provi
Bumek [7]
He could read a biography.
4 0
3 years ago
What are the answers for edhesive quiz 2? I can’t add more than 1 photo...
KatRina [158]

Answer:

i have no idea srry

Explanation:

hi

7 0
3 years ago
Photography is harder with digital cameras than with film cameras.<br>true<br>false
Oliga [24]

the answer is false bc digutal is easeir




7 0
3 years ago
Read 2 more answers
Other questions:
  • You can encrypt individual files, but microsoft recommends encrypting at what level?
    9·1 answer
  • What country is now the number one source of attack traffic?
    5·1 answer
  • Declare a character variable letterStart. Write a statement to read a letter from the user into letterStart, followed by stateme
    12·1 answer
  • Write an expression to print each price in stock_prices. Sample output with inputs: 34.62 76.30 85.05
    9·1 answer
  • Which one of the following, in addition to disciplinary programs and drug-testing, can employers misuse as a form of retaliation
    8·1 answer
  • According to the "multiple-selves" theory, of an online DVD rental service could offer same-day deliveries, so that people who o
    9·1 answer
  • 6.5 Code Practice: Question 1
    13·2 answers
  • Which of the following is an advantage of using variables?
    9·1 answer
  • Write a program to find the sum of first 10 even numbers in qbasic​
    15·1 answer
  • Which of the following could be part of an algorithm?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!