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 two sentences uses the colon correctly?
faust18 [17]
You much list something after a colon.
For example
Kaylina's bag included:
Food,Books,Makeup,and a brush.
5 0
2 years ago
An algorithm that could execute for an unknown amount of time because it depends on random numbers to exit a function may:______
Anna007 [38]

Answer:

c. suffer from indefinite postponement.

Explanation:

Algorithm is a set of rules that are followed in calculations or other problem solving operation by a computer. An algorithm may execute for unknown amount of time and it may suffer indefinite postponement. Algorithm depends on random numbers and it can execute continuously.

8 0
2 years ago
Children walking on the sidewalk, a person sitting in a parked car, and a parking lot with vehicles
Harlamova29_29 [7]

Answer:

Explanation:

Hello friend !!!!!!!!!!!!

The answer is <u><em>school zone</em></u>

Hope this helps

plz mark as brainliest!!!!!!!

6 0
3 years ago
​ A wire service is also known as a ____.
charle [14.2K]
The answer is C press agency
4 0
3 years ago
You have this code in your program.
earnstyle [38]

The line code will create array is G = array('f',[2.5, 3, 7.4])

<h3>What is meant by array ?</h3>

As opposed to defining distinct variables for each value, arrays are used to hold numerous values in a single variable. Set the data type (such as int) and the array name, followed by square brackets [, to construct an array.

An array is a collection of elements with the same type that are kept in nearby memory  locations and may each be separately referred to using an index to a special identifier. There is no need to declare five distinct variables when declaring an array of five int values (each with its own identifier).

In the C programming language, arrays are a derived data type that may contain primitive data types like int, char, double, float, etc.

To learn more about array refer to :

brainly.com/question/28061186

#SPJ1

6 0
11 months ago
Other questions:
  • A haiku is a three-line poem in which the first line contains five syllables, the second line contains seven syllables, and the
    12·1 answer
  • 11.The shortcut keys used to center a paragraph are&lt;br /&gt;a. CTRL+T&lt;br /&gt;b. CTRL+M&lt;br /&gt;c. CTRL+SHIFT+T d. CTRL
    7·1 answer
  • The use of themes in WordPress is a good illustration of what major concept?
    6·1 answer
  • Write an if statement that prints the message ""The number is not valid"" if the variable distance is outside the range 100 thr
    8·1 answer
  • Exercise#3: Write a program that performs the following: Declare a two arrays called arrayA and arrayB that holds integer and th
    14·2 answers
  • What would be used by a business to assess how the business is working within its organization goals? O A. Information systems B
    8·1 answer
  • To discover how many cells in a range contain values that meet a single criterion, use the ___ function
    5·1 answer
  • What is the output of this program? age=4 if age &gt;5: print (“more”) else: print (“less”)
    7·1 answer
  • Which statement is true of the digital sound produced by a computer using a<br> lower sample rate?
    9·1 answer
  • Should a UDP packet header contain both Sour Port # and Destination Port #?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!