Question

Type this script in PyTutor's editor window: import math def area_of_disk(radius): return math.pi * radius **...

Type this script in PyTutor's editor window:

import math

def area_of_disk(radius):

return math.pi * radius ** 2

area = area_of_disk(5.0)

● What is the name of the frame containing variable area_of_disk?

● What does variable area_of_disk refer to?

● What is the name of the frame containing parameter radius?

● When does the frame appear in the frames pane?

● What is the type and value of the object bound to radius? What caused that object to be bound to radius?

● How does PyTutor depict the value the function will return?

● When does the frame containing radius disappear?

● What is the name of the frame containing variable area?

● When does area appear in the frame?

● What is the type and value of the object bound to area? What caused that object to be bound to area?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

What is the name of the frame containing variable area_of_disk?

      Global frame contains area_of_disk

                         --------------------------------------

What does variable area_of_disk refer to?

   area_of_disk refers to the function object

                      --------------------------------------

What is the name of the frame containing parameter radius?

          Global Frame contains parameter radius

                        --------------------------------------

When does the frame appear in the frames pane?

   when the first statement "import math" is executed, math module instance created then first frame    appears. "math" is the reference variable refers to that math module instance.

                          --------------------------------------

What is the type and value of the object bound to radius? What caused that object to be bound to radius?

   radius bound to float data type . Value of the radius is 5.0

   when the function area_of_disk(5.0) is called, parameter 5.0 is passed to
   the function, in the function definition it is assigned to radius variable.

                              --------------------------------------

How does PyTutor depict the value the function will return?

   "return " keyword is used to indicate that the function will
   return a value

                            --------------------------------------

When does the frame containing radius disappear?
  
   when the function return the calculated value, the radius disappear.

                            --------------------------------------

What is the name of the frame containing variable area?

   Global frame

                          --------------------------------------

When does area appear in the frame?

   After the function return the value, area appears in the frame.
   The return value is assigned to area variable.

                                   --------------------------------------
What is the type and value of the object bound to area? What caused that object to be bound to area?

   area bound to float data type. value of area is 78.5398
  
   when the statement area = area_of_disk(5.0) is executed , area_of_disk is called with
   parameter. Then the function calculates the area and return the value.
   The returned value is assigned to area variable.  

                                 --------------------------------------

SCREENSHOT FOR WHEN FIRST FRAME APPEARS:

SCREENSHOT WHEN area_of_disk() FUNCTION OBJECT IS CREATED:

Add a comment
Know the answer?
Add Answer to:
Type this script in PyTutor's editor window: import math def area_of_disk(radius): return math.pi * radius **...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Type up the GeometricObject class (code given on the back of the paper). Name this file Geometric...

    Python only please, thanks in advance. Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...

  • When this Python script is executed, what is bound to y? def square(x: float) -> float:...

    When this Python script is executed, what is bound to y? def square(x: float) -> float: return x * x square(8) Select one: O 64.0 O A square with sides that are 8 units long. O 64 O An object of type function.

  • Python only please, thanks in advance. Type up the GeometricObject class (code given on the back...

    Python only please, thanks in advance. Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...

  • what are the debuggers in Java? import java.text.NumberFormat; /** * * This class represents a circle...

    what are the debuggers in Java? import java.text.NumberFormat; /** * * This class represents a circle that would be used as part * of a larger geometry application */ public class Circle {    private double radius;    private NumberFormat numberFormat; /** *    Constructor for the Circle. * @param radius for the circle */    public Circle(double r) {        radius = r;    } /** *    This method uses the radius of the circle to compute...

  • whats the answer When defining a class which has the field name of type String. How...

    whats the answer When defining a class which has the field name of type String. How is the name field declared? String nam name Opublic String name; private name; private String name; Given the following class definition, Which operation can a class user perform on an object of type Restaurant? public class Restaurant // Info about a restaurant // Internal fields public void setName(String restaurant Name) { // Sets the restaurant's name } public void setRating(int user Rating) { //...

  • Unit 1 Programming Assignment Follow the directions for each of the following questions. Answer the question...

    Unit 1 Programming Assignment Follow the directions for each of the following questions. Answer the question or provide the code in a space below the question. 1. Write the complete script tag set for a script whose line statement is document.write(“Hello, world.”); 2. Build a complete HTML document and include the answer to the previous question such that the page executes the script as the page loads. Open the document in your browser to test the results. 3. Add a...

  • Please answer python questions? class ItemPack ): 21 def-init--(self): self.--storage=[] self. _.jump -1 self. _.mid-self. ..jump...

    Please answer python questions? class ItemPack ): 21 def-init--(self): self.--storage=[] self. _.jump -1 self. _.mid-self. ..jump def __iter.(self) self._.mid-int (len (self..storage)-1)/2.0) self. _.jump 0 return (self def __next..(self): 10 ind self .-_aid+self.--jump if ind<0 or ind >=len (self.--storage): 12 13 14 15 raise StopIteration O vToRet self.--storage [ind] if self.--jump <=0 : self.--Jump 1-self.--Jump - else return (vToRet) self..storage.append (item) return (len(self.--storage)=#0) 17 self.--jump*=-1 19 20def stuff (self, item) 21 22def isEmpty (self) 24def unpack (self): if len (self. .storage)0return...

  • CS 1102 Unit 5 – Programming Assignment In this assignment, you will again modify your Quiz...

    CS 1102 Unit 5 – Programming Assignment In this assignment, you will again modify your Quiz program from the previous assignment. You will create an abstract class called "Question", modify "MultipleChoiceQuestion" to inherit from it, and add a new subclass of "Question" called "TrueFalseQuestion". This assignment will again involve cutting and pasting from existing classes. Because you are learning new features each week, you are retroactively applying those new features. In a typical programming project, you would start with the...

  • Part 1: Using Idle Write a Python Script that Does the Following 1. At the top...

    Part 1: Using Idle Write a Python Script that Does the Following 1. At the top of your program, import the math library as in from math import * to make the functions in the math module available. Create a variable and assign into it a constant positive integer number of your choice. The number should be at most 10. 1 Suppose we call this variable x for this writeup document Try something like x = 4 2. Create another...

  • CS 1102 Unit 5 – Programming Assignment In this assignment, you will again modify your Quiz...

    CS 1102 Unit 5 – Programming Assignment In this assignment, you will again modify your Quiz program from the previous assignment. You will create an abstract class called "Question", modify "MultipleChoiceQuestion" to inherit from it, and add a new subclass of "Question" called "TrueFalseQuestion". This assignment will again involve cutting and pasting from existing classes. Because you are learning new features each week, you are retroactively applying those new features. In a typical programming project, you would start with the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT