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
The _____ element of the wsdl describes the data being exchanged between the web service providers and the consumers, including
sukhopar [10]

message is your answer

3 0
3 years ago
The process of analyzing data to extract information not offered by the raw data alone; it uncovers trends and patterns using te
anygoal [31]

Answer:

The correct answer to the following question is "Data Mining".

Explanation:

It is indeed a method that businesses that are used to transform the raw information towards valuable data. Corporations might learn something about their clients instead of using technology to analyze trends in large quantities of content to create more efficient campaigns, boost revenue as well as reduce costs.

  • It encompasses investigating as well as analyzing huge blocks of documentation to extrapolate useful behavioral patterns.
  • It constructs discernment about what actually happens in certain details, and is already teensy bit mathematical than scripting, but utilizes both.
5 0
3 years ago
A network host with an IP address of 192.168.10.200 wants to send a message to a destination computer with an assigned IP addres
Mariulka [41]

Answer:

A Subnet Mask

Explanation:

A Subnet mask is used by the TCP/IP protocol to determine whether a host is on the local Subnet or on a remote network.

In TCP/IP, the parts of the IP address that are used as the network and host addresses are not fixed, so the destination host address 192.168.10.100 cannot be determined by the network host (192.168.10.200) unless it has more information. This information is supplied in another 32-bit number called a Subnet mask.

4 0
4 years ago
A palindrome is a string that reads the same from left to right and from right to left. Design an algorithm to find the minimum
stepladder [879]

Answer:

Explanation:

The following code is written in Python. It is a recursive function that tests the first and last character of the word and keeps checking to see if each change would create the palindrome. Finally, printing out the minimum number needed to create the palindrome.

import sys

def numOfSwitches(word, start, end):

   if (start > end):

       return sys.maxsize

   if (start == end):

       return 0

   if (start == end - 1):

       if (word[start] == word[end]):

           return 0

       else:

           return 1

   if (word[start] == word[end]):

       return numOfSwitches(word, start + 1, end - 1)

   else:

       return (min(numOfSwitches(word, start, end - 1),

                   numOfSwitches(word, start + 1, end)) + 1)

word = input("Enter a Word: ")

start = 0

end = len(word)-1

print("Number of switches required for palindrome: " + str(numOfSwitches(word, start, end)))

3 0
3 years ago
How do you create a reference page in apa format with all websites?
Gre4nikov [31]
Use Cite This For Me's APA citation generator to create a reference page in APA format with all websites.
6 0
3 years ago
Other questions:
  • The chief architect now needs to design a memory with an addressability of 32 bits. Suppose the architect can only use the same
    6·1 answer
  • propose,two new ,proudly South African ways,which you can visualize that the IoT,can be used at work to make life better.
    12·1 answer
  • What is the benefit to having the user interface integrated into the operating system? a) Power users prefer the added flexibili
    13·1 answer
  • What does nntp stand for?
    12·2 answers
  • Why were american colonists unhappy with king george iii?
    6·2 answers
  • ​what is the best advice to follow when using texting or instant messaging (im) in the workplace
    5·1 answer
  • A computer byte is the amount of data (measured in bits) that CPU can manipulate at one time/
    8·1 answer
  • A user is connected to his personal mobile hotspot device at a library for internet access. He notices the display shows two con
    10·1 answer
  • Karen wants to create a program that will allow the user to input their age. Which of these lines of code should be used?
    11·1 answer
  • (blank) is an expansion card that enables a computer to connect to a network:
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!