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]
3 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]3 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
An aggregate function is _____. A. a function that calculates a statistic such as a subtotal or average B. a mathematical expres
Murrr4er [49]

Answer:

  • A. a function that calculates a statistic such as a subtotal or average.

6 0
2 years ago
How often do you give or receive interpersonal support through social media? Consider times when you’ve exchanged supportive mes
Naily [24]

I receive interpersonal support on almost every sight I go on: even on this one right now! An example of interpersonal support can be a typing editor, I believe.

8 0
3 years ago
Select the correct answer.
Umnica [9.8K]

Answer:

OB. by zooming in on them

hope it helps

7 0
2 years ago
When are computers most vulnerable to threats or damage?
valentinak56 [21]
With virus protection
8 0
3 years ago
50 Points Will Give brainliest Help (right answers only please)
gulaghasi [49]

Answer:

The boss, since it’s none of her business that Delilah’s appointment was for mental health, and asking for a doctor’s note after the fact is harassment, and docking her pay might be illegal.

That's what I think (I hope I'm right).

6 0
2 years ago
Read 2 more answers
Other questions:
  • J=2
    7·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    11·1 answer
  • Instructions
    8·1 answer
  • What invention in the past do you think had a significant impact on our culture/ lifestyle? What do you think will be invented/
    11·1 answer
  • Which of the following examples can be solved with unsupervised learning?
    8·1 answer
  • Can someone help me get spotify premium
    7·2 answers
  • HTML question please help
    5·1 answer
  • I have a problem with my Nintendo DS lite does anyone know how to fix it?
    8·1 answer
  • Does anyone have any tips on how to begin a 10 page Capstone project paper? I've got to write a write a research paper on the ty
    14·2 answers
  • Difference between copy command and cut command
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!