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
Write a function called simulate_several_key_strikes. It should take one argument: an integer specifying the number of key strik
Furkat [3]

Answer:

The solution code is written in Python 3

  1. import random
  2. import string
  3. def simulate_several_key_strikes(l):
  4.    char_set = string.ascii_lowercase
  5.    return ''.join(random.choice(char_set) for i in range(l))
  6. print (simulate_several_key_strikes(10))

Explanation:

The program is aimed to generate random characters and the number of characters generated is dependent on user input. Hence, we will need to import the random module (Line 1). We also import string module so that we can make use of its associated method to generate English letters (Line 2)

Next, we create the function simulate_several_key_strikes that takes one single parameter, l, as input. Within the function body, we use ascii_lowercase method to generate the lowercase letter set and assign it to char_set variable (Line 5). We use random.choice method to randomly pick one of the letter in char_set and join it with an empty string (Line 6). Please note there is a for-loop that will repeatedly generate l-number of character and eventually return it as output.

We test the function by passing 10 as input parameter and we shall get a sample output as follows:

xuiczuskoj

7 0
3 years ago
Data as a service began with the notion that data quality could happen in a centralized place, cleansing and enriching data and
saul85 [17]

Answer: True

Explanation:

 Yes, the given statement is true that the data as the service model basically describe about the data quality which could be happened in the centralized place and also enriching the given data. It also offer the data services to the different types of users, system and applications.

 The data as a service (DaaS) is similar to the software as s service. The DaaS concept is that it is provided according to the requirement of the user such as data and information of the different types of product and services.

 It is technically known as the web delivering service which is offer by the cloud manager and its also perform various types of function.  

7 0
3 years ago
When did time begin?
hram777 [196]

I love Rakshya please accpect ma propoese

7 0
2 years ago
Using the drop-down menu, complete these sentences to describe algorithms. Algorithms are instructions to solve a problem. Algor
vfiekz [6]

Answer:

Algorithms are instructions to solve a problem

Explanation:

6 0
3 years ago
Read 2 more answers
What explains the discrepancy between the number of bytes you can
sergejj [24]

Answer:

This is because, the advertisers report the storage space in decimal while the computer reads the storage space in binary.

Explanation:

The advertisers report the storage space in decimal or base 10 because humans count in decimal, whereas the computer reports the storage space in binary or base 2.

Since the computer storage is in bytes and 8 bits equal 1 byte, It is easier to write a storage space of 1 kB as 1000 B but it is actually supposed to be 1024 B(2¹⁰). So, there is a discrepancy of 1024 B - 1000 B = 24 B.

As  we go higher, the discrepancy increases. For example, 1 MB is advertised as 1000 kB = 1000000 B but is actually supposed to be 1024 kB = 1024 × 1024 B = 1048576 B. So, there is a discrepancy of 1048576 B - 1000000 B = 48576 B.

So, the actual number of bytes on the storage device is actually less than that reported due to the different number systems in which they are reported in. This discrepancy is less in memory cards or flash drives though in which the stated value of storage capacity might be the actual storage size.

Note that the base 10 or decimal system was chosen by advertiser since this is what consumers understand.

8 0
2 years ago
Other questions:
  • Achieving a degree in computer forensics, information technology, or even information systems can provide a strong foundation in
    11·1 answer
  • An analyst is reviewing the logs from the network and notices that there have been multiple attempts from the open wireless netw
    13·1 answer
  • Select all of the uses of presentation software in the workplace.
    8·1 answer
  • Trojan Horse is a malicious program and a virus is a program. <br><br> a. True <br> b. False
    6·1 answer
  • A database administrator (DBA) must have a clear understanding of the fundamental business of an organization, be proficient in
    11·1 answer
  • The presentation layer describes the layer where computers interact with _____
    8·2 answers
  • As a consommé simmers, the meat and eggs coagulate, forming a
    6·1 answer
  • When network cards are communicating, bits can occasionally be corrupted in transmission?
    5·1 answer
  • Neymar machine that Run on electricity
    11·1 answer
  • Jon wants to assign a value to the favorite food variable: favoriteFood! = "Pizza" but gets an error message. What does he need
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!