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
What type of natural disaster stuck haiti in 2010 and killed more than 200,000 people
Aleonysh [2.5K]

Answer:

Earthquake

Explanation:

Around 3 million people were affected by this disaster and it was the most devastating natural disaster ever experienced in Haiti. Roughly 250,000 lives were lost and 300,000 people were injured.

3 0
3 years ago
Read 2 more answers
What type of software is an antivirus?
Kamila [148]

Answer: what type of software is an antivirus?

Answer: A security software

Explanation:

Antivirus software is a type of security software designed to protect users from multiple types of malware, not just viruses. The software is a risk management tool that scans devices regularly and on-demand for known malware and suspicious behavior associated with malware.

6 0
3 years ago
Read 2 more answers
The ________ is the biggest power consumer on a mobile computing device. display CPU memory module hard drive
user100 [1]

Answer:

CPU (Central Processing Unit)

6 0
3 years ago
What is a Windows feature that allows you to temporarily store text?
nata0808 [166]
This would be copy and paste.

When you select a text, you can use your keys CTRL and C to copy that same selected text. After this, you can use the paste feature by selecting CTRL and V. Doing this, your selected text will be copied and pasted to a certain location. 
3 0
3 years ago
From the television industry's point of view, which of the following would be the most desirable viewer?
slava [35]
A 50-year-old African American man
4 0
3 years ago
Other questions:
  • You are creating a budget for your new business.What should you include
    15·1 answer
  • When you compose a message, you want your audience to find the information it needs quickly and to understand what it finds. You
    11·1 answer
  • A typical analog cell phone has a frequency of 850 mhz; a digital phone a frequency of 1950 mhz. compared to the signal from an
    7·1 answer
  • What is one of the benefits of using templates for your email marketing campaigns?
    10·1 answer
  • When using file explorer, the right-hand pane that shows the files and folders of the selected area is called the pane?
    7·1 answer
  • क) मानौं तिमी बसेको समाजमा मान्छेहरूले सधै फोहर फाल्ने गर्नाले वातावरण प्रदूषित
    13·1 answer
  • Helllllllllppppppppppp
    9·1 answer
  • Create a Python program that asks the user in which direction to go? north, South East, or West?
    12·1 answer
  • Consider the following incomplete method. Method findNext is intended to return the index of the first occurrence of the value v
    15·1 answer
  • Which is an example of machine-to-machine communication?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!