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
sleet_krkn [62]
3 years ago
8

Write the function which takes an arbitrary real number p , and returns true if the numeber is equals to some power of 2, i.e. p

=2n for some n . Your task is to implement a recursive function power_of_2 withount using loops and library functions.
Computers and Technology
1 answer:
bezimeni [28]3 years ago
4 0

def power_of_2(p):

   if p == 2:

       return True

   elif p < 2:

       return False

   return power_of_2(p/2)

print(power_of_2(32))

The function keeps dividing the number by 2 until it is equal to 2 or the number ends up being less than 2. If at some point the number is equal to 2, it is a power of 2 otherwise it's not a power of 2.

You might be interested in
Which role is delegated to personnel of the IT department and is responsible for maintaining the integrity and security of the d
enyata [817]

Correct question.

Which role is delegated to personnel of the IT department and how is responsible for maintaining the integrity and security of the data?

Answer:

<u>data custodian</u>

<u>Explanation:</u>

Remember, every organization generates data, and large organizations generate even larger data.

Hence, the role of a data custodian in an organization requires He implements measures to protect the organization's data, store and backup the data, as well as granting access to the data to authorized persons when needed.

3 0
3 years ago
Which method of deleting files can be used in windows xp and vista?
Makovka662 [10]
The correct answer is C.

4 0
3 years ago
Which method adds 10 to the right end of the array?<br> myArray.<br> insert<br> (10)
vladimir1956 [14]

JavaScript has a set of mutator functions that allow you to modify the contents of an array without referencing the individual elements.To add to to myArray we us the push() method

<h3>Adding Elements to an Array</h3>

To add to to myArray we us the push() method

(10)

myArray.push(10)

There are two mutator functions for adding elements to an array: push() and unshift(). The push() function adds an element to the end of an array:

var nums = [1,2,3,4,5]; print(nums); // 1,2,3,4,5 nums.push(6);

print(nums); // 1,2,3,4,5,6

var nums = [1,2,3,4,5]; print(nums); // 1,2,3,4,5 nums[nums.length] = 6; print(nums); // 1,2,3,4,5,6

Learn more about arrays here:

brainly.com/question/24275089

6 0
2 years ago
Who the heck is bts?!?!!!???​
Lana71 [14]

Answer:

they are a k-pop boy band.

6 0
3 years ago
Read 2 more answers
Ideally, Internet of Things (IoT) devices have the ability to:
Stella [2.4K]

Answer:

I believe the answer would be D

8 0
3 years ago
Other questions:
  • What is the magnitude of the largest positive value you can place in a bool? a char? an int? a float?
    14·1 answer
  • Write an expression that evaluates to 1 more than the value in the location pointed to by the integer pointer variable ip. Thus,
    8·1 answer
  • Antivirus software installed to scan and monitor malware activities on a server or workstation would be identified as a ________
    8·1 answer
  • The picture that graphically since the items you use in windows is called
    7·1 answer
  • How many address bits are needed to specify each byte in a 512 byte memory unit?
    5·1 answer
  • Ile 1 cm<br> ?<br> 50 m<br> The an
    5·2 answers
  • Give me at least five main characteristic of irrigation equipment​
    8·1 answer
  • A small company with 100 computers has hired you to install a local area network. All of the users perform functions like email,
    9·1 answer
  • The objective of this task is to use Scapy to estimate the distance, in terms of number of routers, between your VM and a select
    10·1 answer
  • PLZZZZZZZZZZZZZZZ HELP ME OUT!!!!! I SICK AND TIRED OF PEOPLE SKIPING MY QUESTION WHICH IS DUE TODAY PLZ ANSWER ALL OFIT!!!!
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!