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 do you consider to be audit evaluation areas?
skelet666 [1.2K]

Answer:

<em>communications</em><em>,</em><em>risk</em><em>,</em><em>systems</em><em>,</em><em>test</em><em>ins</em><em>,</em><em>procedures</em><em>,</em><em>interviews</em><em>,</em><em>documents</em><em>.</em>

Explanation:

The auditor considers many factors in determining the nature, timing, and extent of auditing procedures to be performed in an audit of an entity's financial statements. One of the factors is the existence of an internal audit function. fn 1 This section provides the auditor with guidance on considering the work of internal auditors and on using internal auditors to provide direct assistance to the auditor in an audit performed in accordance with generally accepted auditing standards.Note: When performing an integrated audit of financial statements and internal control over financial reporting, refer to paragraphs 16-19 of PCAOB Auditing Standard No. 5, An Audit of Internal Control Over Financial Reporting That Is Integrated with An Audit of Financial Statements, for discussion on using the work of others to alter the nature, timing, and extent of the work that otherwise would have been performed to test controls.

Roles of the Auditor and the Internal Auditors

<em>02 </em>

<h2><em>I</em><em> </em><em>HOPE</em><em> </em><em>THIS</em><em> </em><em>HELPS</em><em> </em><em>ALOT</em><em>!</em><em> </em><em>:</em><em>3</em></h2>

3 0
3 years ago
What is the quickest option for adding internet images to a power point presentation
Alex777 [14]

Answer:copy and paste

Explanation:

5 0
3 years ago
Given the value x=false ,y=5 and z=1 what will be the value of F=(4%2)+2*Y +6/2 +(z&amp;&amp;x)?
Bezzdna [24]
<h2>Answer:</h2>

F = 13

<h2>Explanation:</h2>

Given:

x = false

y = 5

z = 1

F = (4%2)+2*Y +6/2 +(z&&x)

We solve this arithmetic using the order of precedence:

<em>i. Solve the brackets first</em>

=> (4 % 2)

This means 4 modulus 2. This is the result of the remainder when 4 is divided by 2. Since there is no remainder when 4 is divided by 2, then

4 % 2 = 0

=> (z && x)

This means (1 && false). This is the result of using the AND operator. Remember that && means AND operator. This will return false (or 0) if one or both operands are false. It will return true (or 1) if both operands are true.

In this case since the right operand is a false, the result will be 0. i.e

(z && x) = (1 && false) = 0

<em>ii. Solve either the multiplication or division next whichever one comes first.</em>

=> 2 * y

This means the product of 2 and y ( = 5). This will give;

2 * y = 2 * 5 = 10

=> 6 / 2

This means the quotient of 6 and 2. This will give;

6 / 2 = 3

<em>iii. Now solve the addition by first substituting the values calculated earlier back into F.</em>

F = (4%2)+2*Y +6/2 +(z&&x)

F = 0 + 10 + 3 + 0

F = 13

Therefore, the value of F is 13

5 0
2 years ago
Which certification can help enhance your job prospects in the role of a computer programmer?
Paraphin [41]
Computer science certification, Linux professionalism, Java certification, Python certification
6 0
3 years ago
Read 2 more answers
Please Help Me!!! 40 Points!! Match the correct definition to each term
fgiga [73]

Answer:

is there anymore to this problem because I would like to help you out more mate.

6 0
3 years ago
Other questions:
  • How can you find Web pages that contain news published during the past week?
    8·1 answer
  • In this exercise we examine in detail how an instruction is executed in a single-cycle datapath. Problems in this exercise refer
    6·1 answer
  • Template files can contain the following items: text, tables, images and lists.
    10·1 answer
  • To combat piracy, many software publishers require users to type in a(n) ____ code, a sequence of numbers and letters in order t
    10·1 answer
  • Taking away iPad privileges when a student hits another child would be considered a(an) ________ principle for decreasing or ext
    10·1 answer
  • All of the following are used to fund private schools except ______
    14·2 answers
  • Write a single statement that assigns avg_sales with the average of num_sales1, num_sales2, and num_sales3.
    15·1 answer
  • What is the major difference between the intranet and extranet?
    11·1 answer
  • Which of the following is the best way to keep up with trends in your industry?
    8·1 answer
  • 9- Write a program in MARIE to add three numbers.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!