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
Which LIKE operator would match a single character?<br><br> *<br> ?<br> []<br> #
algol [13]

Answer:

underscore hope that helps

Explanation:

4 0
2 years ago
Which of the following is true? Group of answer choices worst case time of Heapsort is better than worst cast time of Quicksort
Sav [38]

Answer:

Worst case time of Heapsort is better than worst case time of Quicksort.

Explanation:

Worstcase of Heapsort is nlog(n). Worstcase time of Quicksort is (n^2). Heapsort is comparison based sorting algorithm. Heapsort divides input into sorting. It is a selection sort in which we send maximum inputs for maximum elements at end. Quicksort is divide and conquer algorithm. It is considered as efficient sourcing algorithm.

8 0
3 years ago
ASAP!!!!****** Need help!!!!
m_a_m_a [10]
I think it's right. 
<span>Text, numbers, graphics, or sound represented by discrete digits, such as 1s and 0s.</span>
6 0
2 years ago
Which of the following statements isNOT true about abstract data types (ADTs)?A list is anexample of an ADT.ADTs hide theimpleme
Fynjy0 [20]

Answer:

Java provide all the ADTs you need,therefore you do not need to create any newones.

This statement is not true.

Explanation:

ADTs are those data types which we use but we didn't know their inner working that is how it is working what is happening inside.It is commonly used for Data Structures for example:- In stack we use push and pop operations to insert and to delete element from a stack respectively but we didn't know how it is happening inside.How the stack is implemented and etc.Java provides most of the ADT's but not all.

5 0
2 years ago
Identify 3 distractions for young drivers and explain how you plan to minimize these distractions.
Rom4ik [11]
1 distraction is phones , texting and driving . They could have a system in their car which activated by a voice assistant who could do it al for them
4 0
3 years ago
Other questions:
  • Which activity represents a violation of the licensing agreement
    7·2 answers
  • Your boss wants to utilize some sort of cloud storage for his files so that all of his
    10·2 answers
  • IBF Consultants, LLC provides consulting services in privacy and theft deterrence solutions. Another client has very sensitive d
    7·1 answer
  • Among the many DTP software tools available today, which is regarded as the industry standard for DTP?
    13·2 answers
  • The isometric projection camera technique provides an illusion of perspective by using things like parallax scrolling to create
    10·1 answer
  • Carbon copy others who are..
    14·2 answers
  • Drag each tile to the correct box.
    11·1 answer
  • What are some characteristics of pseudocode? Check all that apply. Pseudocode is an informal way of expressing ideas and algorit
    11·2 answers
  • The maximum number of characters that a cell can contain is
    11·2 answers
  • What is a zerø-day exploit? No go.ogle &gt;:(
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!