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
season is when the weather is not optimal and few tourists of vacation time a shoulder b high c average d low​
cricket20 [7]
Winter is such a season. Travel is lower to colder climate areas such as Canada, but higher to warmer climate areas like Columbia.
7 0
3 years ago
Read 2 more answers
To maintain your body temperature, your body converts chemical potential energy into thermal energy T or F
PilotLPTM [1.2K]
True
This is physics btw
CPE --> TE
4 0
3 years ago
How to reload ingenuity when a pulsating blue thing is there
Hatshy [7]
Todo is very important
4 0
3 years ago
What is the input for air cooler computer science​
Maru [420]

Answer:

cooling

Explanation:

Air cooling is a process of lowering air temperature by dissipating heat. It provides increased air flow and reduced temperatures with the use of cooling fins, fans or finned coils that move the heat out of a casing such as a computer …

5 0
2 years ago
Write measure five safety measures can be taken to stay safe in social media​
alexdok [17]

Answer:

  1. <u>Use a strong password</u>.
  2. <u>Use a different password for each of your social media accounts</u>.
  3. <u>Set up your security answers. </u>
  4. <u>If you have social media apps on your phone, be sure to password protect your device.</u>
  5. <u>Be selective with friend requests. </u>

5 0
2 years ago
Read 2 more answers
Other questions:
  • WILL MARK BRAINLYIST
    15·2 answers
  • What is the full meaning of ICT
    14·2 answers
  • Digital dashboards provide the decision makers with a quick overview of key performance indicators and other key operational sta
    13·1 answer
  • Name and describe the two (2) broad categories of files
    9·1 answer
  • landon starts his computer and gets message, hard drive is not found. He was watching a movie the previous night, what might the
    6·1 answer
  • Durante 10s, la velocidad de rotación y el momento de giro de las ruedas de un coche eléctrico son 100 rpm y 1405,92 Nm, respect
    13·1 answer
  • Name:
    11·1 answer
  • What is the alogarithm for solving the perimeter of a triangle
    11·1 answer
  • SOMEONE PLEASE HELP ME WITH THIS ILL GIVE YOU BRAINLY IF YOU GET IT RIGHT PLEASE!!!!!
    13·2 answers
  • What technology does kroger’s edge technology and amazon’s just walk out technology leverage?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!