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
30 POINTS PLS HELLLLPPP WILL GIVE BRAINLIEST What behavior do elements in a stack follow? first in, last out, or FILO behavior l
ArbitrLikvidat [17]

Answer:

Explanation:

A stack item behaves like Last In First Out, which is equivalent to First In Last Out. FIFO and LILO are also equivalent, but they describe a queue.

6 0
2 years ago
Using a database of precomputed hashes from sequentially calculated passwords called a(n) __________, an attacker can simply loo
shepuryov [24]
Using a database of precomputed hashes from sequentially calculated passwords called a rainbow table, an attacker can simply look up a hashed password and read out the text version. Each column in the rainbow table uses a different reduction function. The function of the table is <span>reversing cryptographic hash functions. </span>
5 0
4 years ago
What document type would be best to communicate sales items from a business to potential customer?
Mandarinka [93]

Answer: Flyer

Explanation: A flyer is a type of advertisement that is used to give out information about a certain product, event, or business. This can help communicate with potential customers.

8 0
3 years ago
In today's society, unethical actions are: A) Easier than ever to get away with, because the general public and insurers are les
ra1l [238]
B I think is the best answer
7 0
3 years ago
Read 2 more answers
350 square feet requires 1 gallon of paint. Assign gallons_paint with the amount of paint required for wall_area. Sample output
Marina CMI [18]
Here's a solution in node.js. Can be easily transcribed to other languages:

var paint_per_sqf = 1/350;
var wall_area = 250.0;
var gallons_paint = wall_area * paint_per_sqf;

console.log(wall_area.toFixed(1) + " square feet wall will need:");
console.log(gallons_paint.toFixed(12) + " gallons of paint");


4 0
3 years ago
Other questions:
  • ll of the following are extra precautions you can take to secure a wireless network EXCEPT ________. Select one: A. turn on secu
    9·1 answer
  • Develop a Matlab program that allows you to plot the entropy of a source with variable output probabilities. We wish to observe
    8·1 answer
  • Two samples of dirt are collected from a suspect's tread in his shoe and a crime scene. The forensic investigator does a gross e
    6·2 answers
  • You are the network administrator for Slimjim, a peripheral device company. The network uses Linux, and you need information on
    10·1 answer
  • PLEASE HELP
    5·1 answer
  • (d) What other services beside cloud-based software may be provided by Internet hosts?[1]
    11·1 answer
  • Create a program that calculates the tip and total for a meal at a restaurant. Type the code into an IDLE IDE editor window and
    5·1 answer
  • What starts with p and ends with orn
    15·2 answers
  • In what ways are super computer different from mainframe computers.​
    10·1 answer
  • if you want to clear a single file, what move instruction would you use? group of answer choices none of the choices file to wor
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!