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
A digital footprint is .
BlackZzzverrR [31]

Your digital footprint is the trail of 'electronic breadcrumbs' you leave behind when you use the internet. It can include the websites you visit, the photos you upload and your interactions with other people on social networks.

3 0
3 years ago
Lime is using social media to ask consumers about the qualities they desire in an electric scooter. The firm hopes to develop a
tresset_1 [31]

Answer:

The correct answer to the following question will be "Product".

Explanation:

  • Product marketing is often a mechanism by which a brand is marketed and delivered to a client. It's also known as the intermediate feature between product innovation and brand recognition or awareness.
  • It's something to which comparison is made when selling a product on the market to the consumer.

Therefore, the Product is the right answer for the above question.

8 0
3 years ago
Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. T
kompoz [17]

Answer:

I can't read that pls reformat, or take picture.

Explanation:

3 0
3 years ago
I WILL GIVE THE CROWN IF CORRECT
alisha [4.7K]

Answer:

foundations

Explanation:

7 0
2 years ago
Read 2 more answers
Advantages of desktop publishing over traditional methods include       
Licemer1 [7]
From what my teacher taught us it would be c.
6 0
3 years ago
Other questions:
  • Your bank contacts you asking you to phone a number supplied in the email.What do you?
    13·2 answers
  • What command would you use to list the text files in your
    7·1 answer
  • What these large numbers in unemployment could mean long term for America?
    6·1 answer
  • What date does GTA 6 come out<br> A. 2020<br> B. 2019<br> C. 2021<br> D. 2022
    10·2 answers
  • What is output when the CarTest application is run? Why?
    11·1 answer
  • Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name
    8·1 answer
  • Is USA TestPrep a test-taking site that won't let you access other windows without kicking you off?
    13·1 answer
  • Which item is essential to know before sketching a navigation menu flowchart?
    7·2 answers
  • What the central difference between negative and positive politeness?
    13·2 answers
  • 3.5 Lesson practice quiz: Edhesive Question 5
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!