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
Hitman42 [59]
4 years ago
7

Write a Python program that has subprograms nested four deep and in which each nested subprogram references local variables, var

iables defined in all of its enclosing subprograms, and global variables.

Computers and Technology
1 answer:
Juliette [100K]4 years ago
6 0

Answer:

Check the explanation

Explanation:

CODE:

global_var = "global" #accessible to all functions

def level0():

level0_var = "level 0" #accessible to level 0,1,2,3

print();

print("Level 0 function:")

print("global variable: ",global_var)

print("local variable 0: ",level0_var)

def level1():

print();

print("Level 1 function:")

level1_var = "level 1" ##accessible to level 1,2,3

print("global variable: ",global_var)

print("local variable 0: ",level0_var)

print("local variable 1: ",level1_var)

def level2():

print();

print("Level 2 function:")

level2_var = "level 2" #accessible to level 2,3

print("global variable: ",global_var)

print("local variable 0: ",level0_var)

print("local variable 1: ",level1_var)

print("local variable 2: ",level2_var)

def level3():

print();

print("Level 3 function:")

level3_var = "level 3" #accessible to level 3

print("global variable: ",global_var)

print("local variable 0: ",level0_var)

print("local variable 1: ",level1_var)

print("local variable 2: ",level2_var)

print("local variable 3: ",level3_var)

level3()

level2()

level1()

level0()

Kindly check the attached image below to see the output  (indentations are important):

You might be interested in
Briefly describe the fundamental differences between project-based and product-based Software Engineering.
andrew11 [14]

Answer:

Product-based companies make a specific product and try to market it as a solution. But project-based companies create a solution based on many products and sell it as a packaged solution to a particular need or problem.

Explanation:

hope this helps

8 0
3 years ago
Match the Windows installation technique to its description.
Black_prince [1.1K]

Answer:

There are three techniques description and their names given as below:

1. You install the operating system from a CD but do not need to stay with the computer during the process is called <u>Automated Installation.</u>

2. You install the operating system from a CD, and stay with the computer during the process to input information. It is called <u>Standard installation.</u>

3. You install the operating system from a driver, and stay with the computer during the process to input information. it is called <u>Network installation.</u>

7 0
3 years ago
Extend the flow properties and definitions to the multiple-source, multiple- sink problem. Show that any flow in a multiple-sour
Mkey [24]

Answer:

We add a super source s and add a directed edge (s, si) with capacity c(s, si) = ∞ for each i = 1, 2, . . . , m. We also create a new super sink t and add a directed edge (ti, t) with capacity c(ti, t) = ∞ for each i = 1, 2, . . . , n. The single source s simply provides as much flow as desired for the multiple sources si, and the single sink t likewise consumes as much flow as desired for the multiple sinks ti.

Because the virtual edges of s and t can consume as much flows as they want, they don't influence the actual edges.

Explanation:

7 0
4 years ago
Wrire a code that display elements at indices 1 and 4 in the follwoing array.
Sveta_85 [38]

Answer:

Console.log(userArray[1]);

Console.log(userArray[4]);

Explanation:

The programming language was not stated; however, the variable declaration implies JavaScript.

JavaScript prints using the following syntax:

Console.log(print-name);

Since, the code is to print some elements of array userArray.

First, we need to determine the index of the elements.

The indices are given as 1 and 4.

So, the code to print these elements is as follows:

Console.log(userArray[1]);

Console.log(userArray[4]);

8 0
3 years ago
In a ____ queue, customers or jobs with higher priorities are pushed to the front of the queue.
saul85 [17]

Answer: In a priority queue, customers or jobs with higher priorities are pushed to the front of the queue.

Explanation:

A queue is an abstract data type which is an ordered set of elements. The elements are served in the order in which they join the queue. The first element which was put in the queue is processed first.  

The operations performed on queue data type are dequeue and enqueue.

Dequeue refers to removal of the first element from the queue after it has been serviced.

Enqueue refers to the arrival of new element when the element is added at the end of the queue.

A priority queue is another implementation of a queue. All the elements in a priority queue are assigned a priority. The element with the higher priority is served before the element with a lower priority. In situations of elements having same priority, the element is served based on the order in which the element joined the queue.

In programming, a priority queue can be implemented using heaps or an unordered array. Unordered array is used based on the mandatory operations which are performed on the priority queue.

The mandatory operations supported by a priority queue are is_empty, insert_with_priority and pull_highest_priority_element. These operations are implemented as functions in programming.

The is_empty confirms if the queue is empty and has no elements.

The insert_with_priority puts the new element at the appropriate position in the queue based on its priority. If the priority of the element is similar to the priority of other element, the position of the new element is decided based on the order of joining the queue.

The pull_highest_priority_element pulls the element having the highest priority so that it can be served before other elements. The element having the highest priority is typically the first element in the priority queue.

In operating system, priority queue is implemented to carry out the jobs and/or tasks based on their priority.

4 0
3 years ago
Other questions:
  • Mention any six profession related to tourism
    6·2 answers
  • I want to be a teacher some day and i know this question------------- Humans have a nose to breath , but what do fishes use to h
    6·2 answers
  • The integer variables first and last have been declared and assigned values (with last &gt;= first). Allocate an integer array t
    10·1 answer
  • A user prefers an external monitor, mouse, and keyboard for a laptop. The user does not want to use the built-in screen; however
    5·1 answer
  • If you have four documents open and click the x button on the title bar, _____.
    8·1 answer
  • What feature adjusts the top and bottom margins so that the text is centered vertically on the printed page?
    14·1 answer
  • 1. What was the very first “photo-realistic CGI character” to appear on-screen in a movie (released in 1985)?
    8·2 answers
  • What necessarily happens when a photographer chooses to give either the aperture or the shutter speed priority?
    10·1 answer
  • A person is sledding down a hill at a speed of 9 m/s. The hill gets steeper and his speed increases to 18 m/s in 3 sec. What was
    6·1 answer
  • Doctrine Creative is a video production company with its own file server within its business office. The company needs to be abl
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!