All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Hire a Tutor
AI Study Help
New
Search
Search
Sign In
Register
study help
computer science
starting out with python
Questions and Answers of
Starting Out With Python
What does a subclass inherit from its superclass?
Write an Employee class that keeps data attributes for the following pieces of information:• Employee name• Employee numberNext, write a class named ProductionWorker that is a subclass of the
What does it mean to say there is an “is a” relationship between two objects?
True or FalseIt is not possible to call a superclass’s _ _init_ _ method from a subclass’s _ _init_ _ method.
Look at the following class definition. What is the name of the superclass? What is the name of the subclass?class Hammer(Tool):
Look at the following class definitions:class Art:def _ _init_ _(self, art_type):self._ _art_type = art_typedef message(self):print("I'm a piece of art.")class Painting(Art):def _ _init_
In a particular factory, a shift supervisor is a salaried employee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bonus when his or her shift meets production
Suppose a program uses two classes: Airplane and JumboJet. Which of these would most likely be the subclass?a. Airplaneb. JumboJetc. Bothd. Neither
True or FalseA subclass can have a method with the same name as a method in the superclass.
What is an overridden method?
Look at the following class definition:class Bird:def _ _init_ _(self, bird_type):self._ _bird_type = bird_typeWrite the code for a class named Duck that is a subclass of the Bird class. The Duck
Write a class named Person with data attributes for a person’s name, address, and telephone number. Next, write a class named Customer that is a subclass of the Person class. The Customer class
Look at the following code, which is the first line of a class definition. What is the name of the superclass? What is the name of the subclass?class Canary(Bird):
This characteristic of object-oriented programming allows the correct version of an overridden method to be called when an instance of a subclass is used to call it.a. Polymorphismb. Inheritancec.
Look at the following class definitions:Given these class definitions, what will the following statements display?v = Vegetable('veggie')p = Potato()v.message()p.message() class
True or FalseOnly the _ _init_ _ method can be overridden.
You can use this to determine whether an object is an instance of a class.a. The in operatorb. The is_object_of functionc. The isinstance functiond. The error messages that are displayed when a
True or FalseYou cannot use the isinstance function to determine whether an object is an instance of a subclass of a class.
A recursive function _______________.a. Calls a different functionb. Abnormally halts the programc. Calls itselfd. Can only be called once
What will the following program display?def main():word = 'test'show_me(word)def show_me(word):print(word)new_word = word[1:]if len(new_word) > 0:show_me(new_word)main()
Design a recursive function that accepts an integer argument, n, and prints every second number from n down to a minimum of 0. Assume that n is always a positive integer.
A function is called once from a program’s main function, then it calls itself four times. The depth of recursion is _______________.a. Oneb. Fourc. Fived. Nine
In this chapter, the rules given for calculating the factorial of a number are as follows:If n = 0 then factorial(n) = 1If n > 0 then factorial(n) = n * factorial(n - 1)If you were designing a
How many times will the halver function be called when the following code is run?def main():num = 10halver(num)def halver(number):print(number)half = number / 2if half >= 1:halver(half)main()
When function A calls function B, which calls function A, it is called _______________ recursion.a. Implicitb. Modalc. Directd. Indirect
Design a function that accepts a string as an argument. Assume that the string will contain a single word. The function should use recursion to determine whether the word is a palindrome (a word that
Any problem that can be solved recursively can also be solved with a _______________.a. Decision structureb. Loopc. Sequence structured. Case structure
Actions taken by the computer when a function is called, such as allocating memory for parameters and local variables, are referred to as _______________.a. Overheadb. Set upc. Clean upd.
A recursive algorithm must _______________ in the recursive case.a. Solve the problem without recursionb. Reduce the problem to a smaller version of the original problemc. Acknowledge that an error
A recursive algorithm must _______________ in the base case.a. Solve the problem without recursionb. Reduce the problem to a smaller version of the original problemc. Acknowledge that an error has
True or FalseThe Python language has built-in keywords for creating GUI programs.
When a program runs in a text-based environment, such as a command line interface, what determines the order in which things happen?
Write a GUI program that displays your name and address when a button is clicked. The program’s window should appear as the sketch on the left side of Figure 13-42 when it runs. When the user
Write a statement that creates a Label widget. Its parent should be self.main_ window, and its text shoud be 'Programming is fun!'
The _______________ is the part of a computer with which the user interacts.a. Central processing unitb. User interfacec. Control systemd. Interactivity system
True or FalseEvery widget has a quit method that can be called to close the program.
What does a widget’s pack method do?
Assume self.label1 and self.label2 reference two Label widgets. Write code that packs the two widgets so they are positioned as far left as possible inside their parent widget.
How does a command line interface work?
Before GUIs became popular, the _______________ interface was the most commonly used.a. Command lineb. Remote terminalc. Sensoryd. Event-driven
True or FalseThe data that you retrieve from an Entry widget is always of the int data type.
What does the tkinter module’s mainloop function do?
Write a statement that creates a Frame widget. Its parent should be self.main_ window.
When the user runs a program in a text-based environment, such as the command line, what determines the order in which things happen?
A _______________ is a small window that displays information and allows the user to perform actions.a. Menub. Confirmation windowc. Startup screend. Dialog box
If you create two widgets and call their pack methods with no arguments, how will the widgets be arranged inside their parent widget?
Write a GUI program that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, then see the equivalent Fahrenheit
Write a statement that displays an info dialog box with the title “Program Paused” and the message “Click OK when you are ready to continue.”
What is an event-driven program?
These types of programs are event driven.a. Command lineb. Text-basedc. GUId. Procedural
How do you specify that a widget should be positioned as far left as possible inside its parent widget?
Write a statement that creates a Button widget. Its parent should be self.button_ frame, its text should be 'Calculate', and its callback function should be the self. calculate method.
A county collects property taxes on the assessment value of property, which is 60 percent of the property’s actual value. If an acre of land is valued at $10,000, its assessment value is $6,000.
Briefly describe each of the following tkinter widgets:a) Labelb) Entryc) Buttond) Frame
An item that appears in a program’s graphical user interface is known as a(n) _______________.a. Gadgetb. Widgetc. Toold. Iconified object
How do you retrieve data from an Entry widget?
Write a statement that creates a Button widget that closes the program when it is clicked. Its parent should be self.button_frame, and its text should be 'Quit'.
Joe’s Automotive performs the following routine maintenance services:• Oil change—$30.00• Lube job—$20.00• Radiator flush—$40.00• Transmission flush—$100.00•
How do you create a root widget?
You can use this module in Python to create GUI programs.a. GUIb. PythonGuic. Tkinterd. Tgui
How can you use a StringVar object to update the contents of a Label widget?
Assume the variable data_entry references an Entry widget. Write a statement that retrieves the data from the widget, converts it to an int, and assigns it to a variable named var.
What does the tkinter module’s mainloop function do?
This widget is an area that displays one line of text.a. Labelb. Entryc. TextLined. Canvas
How can you use an IntVar object to determine which Radiobutton has been selected in a group of Radiobuttons?
Assume that in a program, the following statement creates a Canvas widget and assigns it to the self.canvas variable: self.canvas = tkinter.Canvas(self.main_window, width=200, height=200)Write
Use the Canvas widget that you learned in this chapter to draw a house. Be sure to include at least two windows and a door. Feel free to draw other objects as well, such as the sky, sun, and even
What does a widget’s pack method do?
This widget is an area in which the user may type a single line of input from the keyboard.a. Labelb. Entryc. TextLined. Input
How can you use an IntVar object to determine whether a Checkbutton has been selected?
Counting the growth rings of a tree is a good way to tell the age of a tree. Each growth ring counts as one year. Use a Canvas widget to draw how the growth rings of a 5-year-old tree might look.
If you create two Label widgets and call their pack methods with no arguments, how will the Label widgets be arranged inside their parent widget?
Make your own star on the Hollywood Walk of Fame. Write a program that displays a star similar to the one shown in Figure 13-43, with your name displayed in the star. Figure 13-43 Hollywood
This widget is a container that can hold other widgets.a. Grouperb. Composerc. Fenced. Frame
What argument would you pass to a widget’s pack method to specify that it should be positioned as far left as possible inside the parent widget?
This method arranges a widget in its proper position, and it makes the widget visible when the main window is displayed.a. Packb. Arrangec. Positiond. Show
Using the shapes you learned about in this chapter, draw the outline of the vehicle of your choice (car, truck, airplane, and so forth).
How do you retrieve data from an Entry widget?
A(n) _______________ is a function or method that is called when a specific event occurs.a. Callback functionb. Auto functionc. Startup functiond. Exception
Use a Canvas widget to draw each of the planets of our solar system. Draw the sun first, then each planet according to distance from the sun (Mercury, Venus, Earth, Mars, Jupiter Saturn, Uranus,
When you retrieve a value from an Entry widget, of what data type is it?
The showinfo function is in this module.a. Tkinterb. Tkinfoc. Sysd. Tkinter.messagebox
What module is the StringVar class in?
What can you accomplish by associating a StringVar object with a Label widget?
You call this method to retrieve data from an Entry widget.a. Get_entryb. Datac. Getd. Retrieve
An object of this type can be associated with a Label widget, and any data stored in the object will be displayed in the Label.a. StringVarb. LabelVarc. LabelValued. DisplayVar
If there are a group of these in a container, only one of them can be selected at any given time.a. Checkbuttonb. Radiobuttonc. Mutualbuttond. Button
How can you use an IntVar object to determine which Radiobutton has been selected in a group of Radiobuttons?
The ___________ widget provides methods for drawing simple 2D shapes.a. Shapeb. Drawc. Paletted. Canvas
How can you use an IntVar object to determine whether a Checkbutton has been selected?
In the Canvas widget’s screen coordinate system, what are the coordinates of the pixel in the upper-left corner of the window?
Using the Canvas widget’s screen coordinate system with a window that is 640 pixels wide by 480 pixels high, what are the coordinates of the pixel in the lower-right corner?
How is the Canvas widget’s screen coordinate system different from the Cartesian coordinate system used by the turtle graphics library?
What Canvas widget methods would you use to draw each of the following types of shapes?a) A circleb) A squarec) A rectangled) A closed six-sided shapee) An ellipsef) An arc
You can call this method to close a GUI program.a. The root widget’s destroy methodb. Any widget’s cancel methodc. The sys.shutdown functiond. The Tk.shutdown method
You use a(n) __________ statement to write a dual alternative decision structure.a. Test-jumpb. Ifc. If-elsed. If-call
Write an if-else statement that determines whether the points variable is outside the range of 9 to 51. If the variable’s value is outside this range it should display “Invalid points.”
A class has two tests worth 25 points each along with a main exam worth 50 points. For a student to pass the class, they must obtain an overall score of at least 50 points, and must obtain at least
And, or, and not are __________ operators.a. Relationalb. Logicalc. Conditionald. Ternary
Write an if statement that uses the turtle graphics library to determine whether the turtle’s heading is in the range of 0 degrees to 45 degrees (including 0 and 45 in the range). If so, raise the
Showing 700 - 800
of 839
1
2
3
4
5
6
7
8
9