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
Casting is one of the oldest known manufacturing processes. <br> True or false
alexandr1967 [171]
I think the answer is true because casting has been found 6000 years ago!
7 0
3 years ago
Read 2 more answers
January 19/May 16 2022
fenix001 [56]

Answer:

This should get you started. Many things could be improved. You could keep adding layers to this program if you wanted to, so I wrote it with that in mind.

The new salary depends on the employee's department and current salary. I created a class that represents each employee. The function looks at the employee's current salary, and looks up what the employee's department raise will be (using the dictionary/hash table) before performing the calculation.

3 0
2 years ago
how old is the letter 3 on its 23rd birthday when your car turns 53 and your dog needs gas and your feet need lave then when is
forsale [732]

Answer:

ummm...idr.k..u got me....wat is it

Explanation:

8 0
3 years ago
Assume you are on the only person to write program on this system. Assume the system's OS uses the "priority-scheduling" schedul
kondor19780726 [428]

Answer:

1. Write all programs to have the same priority.

Explanation:

Write all programs to have same priority. So that there will be no context switching in between.

7 0
3 years ago
Write two scnr.nextInt statements to get input values into birthMonth and birthYear. Then write a statement to output the month,
Firlakuza [10]

Answer:

Here is code in Java.

// import package

import java.util.*;

class Main

{   // main method of class

public static void main (String[] args) throws java.lang.Exception

{

   try{

       // variables to store the input

       int birthMonth,birthYear;

       // Scanner class object to read the input

       Scanner scnr=new Scanner(System.in);

       System.out.print("Please enter the birth month:");

       // read the birth month

       birthMonth=scnr.nextInt();

       System.out.print("Please enter the birth year:");

       // read the birth year

       birthYear=scnr.nextInt();

       // print the output

       System.out.println(birthMonth+"/"+birthYear+"\n");

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create two variables "birthMonth" & "birthYear" to store the birth month and birth year.Read the  values of both from user. Print the birth month and birth year separated by a slash("/").

Output:

Please enter the birth month:1                                                                                                

Please enter the birth year:2000                                                                                              

1/2000  

Please enter the birth month:5                                                                                                

Please enter the birth year:1950                                                                                              

5/1950  

7 0
3 years ago
Other questions:
  • g Create a public non-final generic class called YourSimpleLinkedList. You should extend SimpleLinkedList which is parameterized
    10·1 answer
  • What is the Web of Trust?
    12·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    14·1 answer
  • What is the different between 32bit anf 64 bit verision​
    11·1 answer
  • If my computer is next to my book, what preposition would I use?<br> O xià<br> 0 shàng<br> pangbian
    7·1 answer
  • When a module is executing what happens when the end of the module is reached?
    10·1 answer
  • How can you change your mindset ? What are some fears you have had to overcome related to school ?
    10·1 answer
  • What type of Microsoft Server serves as an email server?
    7·2 answers
  • (10 points) Make a user interface to get 3 points from the user which will be placed on the coordinate plane. Then write a Pytho
    11·1 answer
  • Submit a report outlining the steps you will take to obtain digital evidence. In your report you must include the legal requirem
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!