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
Write a program that reads and unspecified number of integers, determines how many positive and negative values have been read,
KonstantinChe [14]

Answer:

The program was wrote in the version 3.9.5 of python and it's in the homework.txt file.

Download txt
6 0
3 years ago
What's the answer plssss​
Savatey [412]

Answer:

TELL IT TO YOUR TEACHERS HOW

8 0
3 years ago
Straight dinosaur walks out of woods : RAWWRRRR
Lena [83]

Answer:

These type of people on brainly are what I live for L M A O

Explanation:

4 0
3 years ago
Read 2 more answers
__________ software helps the computer carry out its basic operating tasks.
Ahat [919]
System software is the answer.
3 0
4 years ago
Which statement identifies what the students will be graded on?
Tju [1.3M]
A, although I may be wrong.
5 0
4 years ago
Read 2 more answers
Other questions:
  • Using a wireless network without the network owner's permission is known as ________.
    15·1 answer
  • If a user copies the formula D15 into D16, what would the formula read in D16?
    15·2 answers
  • When you type into a basic search engine like Google, Bing, or Yahoo!, the sites that appear at the top or on the side of the re
    7·1 answer
  • Are goals that<br> have concrete criteria for measuring<br> progress toward their attainment.
    5·1 answer
  • ____ is a real-time Internet communications service that notifies users when one or more people are online and then allows them
    10·1 answer
  • Explain the role of the network layer and Internet protocol (IP) in order to make internetworking possible.
    8·1 answer
  • True/False: When a programmer creates an abstract data type, he or she can decide what values are acceptable for the data type,
    8·1 answer
  • A file with a com extension is most likely to be a(n) ___ file.
    13·2 answers
  • Rewrite the following using if else statement:
    14·1 answer
  • Which of the following is the most accurate definition of a botnet? a small text file passed to a Web browser on a user's comput
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!