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
Nimfa-mama [501]
3 years ago
9

Will the Python code below print something? And will it terminate?

Computers and Technology
1 answer:
77julia77 [94]3 years ago
3 0

Answer:

Yes and Yes

Explanation:

When programs are written without indentation; it becomes a problem to read;

I'll rewrite your program as follows:

<em>def print_n(s, n):  </em>

<em>    if n > 0:  </em>

<em>        print(s)  </em>

<em>        print_n(s, n-1)  </em>

<em>    return n  </em>

<em>n = 3  </em>

<em>while print_n("hi", n):  </em>

<em>    print_n("there!", n)  </em>

<em>    n = 0</em>

<em />

Using the above as a point of reference,

Yes, the program will run and Yes, it'll terminate;

Because n is initialized to 3 at line 6 (where the main starts);

The following is passed to the function; s = "hi" and n=3

This prints "hi", three times

s = "there" and n=3 is then passed to the function print_n, afterwards;

The function then prints "there" three times

Then, the program terminates

You might be interested in
What is the purpose of a search engine?
soldi70 [24.7K]
The purpose is to look for the topic that you need to ask a question and to find/get to a website you want to go to. hope this helped :)
4 0
4 years ago
Read 2 more answers
Which arrangement shows the strongest gravitational effects of the sun and moon on the earth's tides?
julia-pushkina [17]
C rain tides is right
3 0
4 years ago
Complete the sentence to identify advantages of top-down programming design. Choose all that apply.
yanalaym [24]

Answer:The original choice to write apply_fg so that it accepts function arguments is a good one, because it increases interoperability. When the callable arguments to apply_fg use a single protocol, we can easily exchange them: #include <functional> float log2(float); int a = apply_fg(5.Of, int b = apply_fg(3.14f,

Explanation:

3 0
4 years ago
Read 2 more answers
How are computers located on a network
Luba_88 [7]

Answer:

<em>When computers connect on the same network, it is called a local area network, or LAN. </em>

Explanation:

<em>The router is given the IP address for your connection to the Internet and then assigns local IP addresses to each device in your network.</em>

<em />

<em>Hope this can help you </em>

8 0
3 years ago
Suzy lives alone I. New York where her family lives In Florida
ankoles [38]

Answer:

bro what

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • which quotation from the story of the fisherman in the Arabian nights' entertainments supports the theme that cleverness trumps
    15·1 answer
  • How is an orthographic drawing similar or different from an isometric drawing
    12·1 answer
  • What is the difference between primary storage, secondary storage and off-line storage?
    5·1 answer
  • The region which satisfies all of the constraints in graphical linear programming is called the:
    8·1 answer
  • Create a Python program by defining a function that calculates the year of birth of a person whose age is known to you.(You may
    7·1 answer
  • What are 6 steps to take to figure out what's wrong with your computer?
    5·1 answer
  • The addresses a program may use to reference memory are distinguished from the addresses the memory system uses to identify phys
    15·1 answer
  • Which function in spreadsheet software can be used to predict future sales or inventory needs?
    5·2 answers
  • 1. Why are condition statements important for programming?
    11·1 answer
  • What is an example of new technology having a negative impact on sustainability?.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!