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
AfilCa [17]
4 years ago
9

Write the definition of a function named printpoweroftwostars that receives a non-negative integer n and prints a line consistin

g of "2 to the n" asterisks. so, if the function received 4 it would print 2 to the 4 asterisks, that is, 16 asterisks: **************** and if it received 0 it would print 2 to the 0 (i.e. 1) asterisks: * the function must not use a loop of any kind (for, while, do-while) to accomplish its job
Computers and Technology
1 answer:
Aleksandr-060686 [28]4 years ago
4 0
To accomplish this without using a loop,
we can use math on a string.

Example:
print("apple" * 8)

Output:
appleappleappleappleappleappleappleapple

In this example,
the multiplication by 8 actually creates 8 copies of the string.

So that's the type of logic we want to apply to our problem.

<span>def powersOfTwo(number):
if number >= 0:
return print("*" * 2**number)
else:
<span>return

Hmm I can't make indentations in this box,
so it's doesn't format correctly.
Hopefully you get the idea though.

We're taking the string containing an asterisk and copying it 2^(number) times.

Beyond that you will need to call the function below.
Test it with some different values.

powersOfTwo(4) should print 2^4 asterisks: ****************</span></span>
You might be interested in
Which version represents the video project after the assembly cut has been completed, transitions and special effects have been
yuradex [85]

Answer:

D.final cut

Explanation:

it well help for the non-liris editing in film or others

7 0
3 years ago
After reading through the code, what will happen when you click run?​
AnnyKZ [126]

Answer:

B.) Laurel will try to collect treasure when there is not any and it causes an error

Explanation:

Laurel is at the top right corner of the map. When you click run, laurel moves 1 step ahead. This spot is right above the coordinate of the very first diamond. There is no treasure at this spot.

Therefore, when the next command calls for collecting, there will be an error, as there is no treasure at the spot right above the first diamond.

4 0
3 years ago
. Alex discovered a bunch of SATA drives in a box at the office and needs to check the contents. What can he do so that Windows
ZanzabumX [31]

You have to make sure the BIOS boot is set to the normal hard drive first, then plug in the SATA cable and power properly

8 0
3 years ago
the piece of hardware that contains the circuitry that processes the information coming in to the computer and tells the other h
vagabundo [1.1K]

that sound like the CPU, the central processing unit, it handles the informations and distributes it.

7 0
3 years ago
My computer keeps on logging me out when i try to answer a question on brainly. Can somebody please explain why. And give a good
fomenos

Answer:

it could be your internet

Explanation:

mine used to do it to me because of internet and since everyone is one the internet because of the Coronavirus everyone is working online that could be the case

:)

8 0
4 years ago
Read 2 more answers
Other questions:
  • When driving a truck is fuel crucial
    9·1 answer
  • Is my answer is right? Someone tell me immediately!!!
    11·1 answer
  • Which line of code will print Python is cool! on the screen?
    9·2 answers
  • Ophelia is entering a Get Fit! sporting goods store in a shopping mall when her heel gets caught in a heating grate at the thres
    9·1 answer
  • The biggest risk for the elderly when considering technology is
    11·1 answer
  • An unauthorized user is a network _______ issue.
    11·1 answer
  • Is the following sentence true or false? During meiosis, the two alleles for each gene stay together. ______
    15·1 answer
  • Select the correct answer.
    14·1 answer
  • Convert Fahrenheit to Celsius using this formula: F = (9/5)*C+32
    5·1 answer
  • Older systems that often contain data of poor quality are called ________ systems.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!