QUESTION 31
The tkinter command _____ kicks off the GUI event loop.
goloop() |
||
doloop() |
||
mainloop() |
||
loopDloop() |
2.5 points
QUESTION 32
Which of the following statements about superclasses and subclasses is true?
A subclass is not connected to a super class in any way |
||
A superclass inherits from a subclass. |
||
A superclass extends a subclass. |
||
A subclass extends a superclass. |
2.5 points
QUESTION 33
Pickled objects can be loaded into a program from a file using the function ____.
pickle.load |
||
cPickle.read |
||
cPickle.input |
||
cPickle.pickleIn |
2.5 points
QUESTION 34
How many constructors can be defined for each class?
classes don't have constructors |
||
Only one constructor may be defined |
||
"At least one, but as many as needed" |
||
"At least one, but no more than five" |
2.5 points
QUESTION 35
A description of encapsulation would include the act of hiding the implementation details
True
False
2.5 points
QUESTION 36
For the following code the variable named name1 ____.
val = StringVar()
name1 = Entry(root, width=5, textvariable=val)
holds a reference to the Entry box object. |
||
contains any text that the user might have typed into the entry box |
||
contains the value None |
||
holds the value of True |
2.5 points
QUESTION 37
"Which of the following method headers represent a constructor, assuming we add a colon to each?"
def init(self) |
||
def __init__(self) |
||
def _init(self) |
||
def init() |
2.5 points
QUESTION 38
The first parameter in a widget constructor, if not used in a class, is the name of the containing element. Pick True for this answer.
True
False
3.5 points
QUESTION 39
Using a try-except block you would filter for the existance of an error in opening a file by using the IOError error type
True
False
2.5 points
QUESTION 40
What prints when this runs?
class Amphibians :
def __init__(self, name="amphibian") :
self.name = name
def display(self) :
print(self.name)
class Frog(Amphibians) :
def __init__(self, name) :
self.name = name
super().__init__(name)
f = Frog('Kermit')
f.display()
amphibian |
||
Kermit |
||
None |
||
Frog |
Answer 31:mainloop()
Answer 32:A subclass extends a superclass.
Answer 33:pickle.load
Answer 34:"At least one, but as many as needed"
Answer 35:False
Answer 36:contains any text that the user might have typed into the
entry box
Answer 37:def __init__(self)
Answer 38:True
Answer 39:True
Answer 40:Kermit
QUESTION 31 The tkinter command _____ kicks off the GUI event loop. goloop() doloop() mainloop() loopDloop()...
Using the following code: store.py from abc import ABC,abstractmethod class Store(ABC): #creating a abstract class name='' #declaring attributes in class address='' status='' sales_tax_percentage=0.0 def __init__(self,name,address,status,sales_tax_percentage): #init method to initialize the class attributes self.name=name self.address=address self.status=status self.sales_tax_percentage=sales_tax_percentage def get_name(self): #Getter and setter methods for variables return self.name def set_name(self,name): self.name=name def get_address(self): return self.address def set_address(self,address): self.address=address def set_status(self,status): self.status=status def get_status(self): return self.status def set_sales_tax_percentage(self,sales_tax_percentage): self.sales_tax_percentage=sales_tax_percentage def get_sales_tax_percentage(self): return self.sales_tax_percentage def is_store_open(self): #check store status or availability if self.status=="open": #Return...
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...
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...
In this question, you will complete the FootballPlayer class, which is used to compute some features of a Football Player. The class should be constructed with the name and age, as well as shooting, passing, tackling and saving skill points of a player. The constructor method as well as the defenderScore method is provided below. You should implement the remaining methods. The definitons of the methods are presented below as comments. An example execution and the corresponding outputs are provided below: >>> burkay = FootballPlayer("Burkay", 42, 15, 30, 10, 15) >>> cemil = FootballPlayer("Cemil", 30, 70, 30, 45, 20) >>> ronaldo = FootballPlayer("Ronaldo", 36, 85, 95, 35, 5) >>> print(burkay) (Burkay,42,13640000) >>> print(cemil) (Cemil,30,144270000) >>> print(ronaldo) (Ronaldo,36,322445000) >>> print(burkay > cemil) False >>> print(ronaldo > burkay) True """ class FootballPlayer: def __init__(self, na, ag, sh, pa, ta, sa): # age is in [18,40] # skills are in [10,100] self.name = na self.age = ag self.shooting = sh self.passing = pa self.tackling = ta self.saving = sa def defenderScore(self): # The defensive score is defined as 80% tackling, 15% passing and 5% shooting # It should be reported as integer return int(0.80 * self.tackling + 0.15 * self.passing + 0.05 * self.shooting) def midfielderScore(self): # The midfielder score is defined as 50% passing, 25% shooting and 25% tackling # It should be reported as integer return # Remove this line to answer this question def forwardScore(self): # The forward score is defined as 70% shooting, 25% passing and 5% tackling # It should be reported as integer return # Remove this line to answer this question def goalieScore(self): # The goalie score is defined as 90% saving and 10% passing # It should be reported as integer return # Remove this line to answer this question def playerValue(self): # Player value is defined as # * 15000$ per unit of the square of defensive score # * 25000$ per unit of the square of midfielder score # * 20000$ per unit of the square of forward score # * 5000$ per unit of the square of goalie score # * -30000$ per (age-26)^2 # A player's value is never reported as negative. The minimum is 0. # It should be reported as integer return # Remove this line to answer this question def __str__(self): # This method returns a string representation of the player, such as # "(name,age,playerValue)" return # Remove this line to answer this question def __gt__(self, other): # This method returns True if the player value of self is greater than # the player value of other. Otherwise, it returns False. return # Remove this line to answer this question
PYTHON QUESTION... Building a Binary Tree with extended Binary Search Tree and AVL tree. Create a class called MyTree with the methods __init__(x), getLeft(), getRight(), getData(), insert(x) and getHeight(). Each child should itself be a MyTree object. The height of a leaf node should be zero. The insert(x) method should return the node that occupies the original node's position in the tree. Create a class called MyBST that extends MyTree. Override the method insert(x) to meet the definitions of a...
Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts What code is human-readable and follows the standards of a programming language? Secret code Source code Key code None of these Machine code Question 3 2 pts What is the symbol that marks the beginning of a one line comment? Question 1 2 pts The preprocessor executes after the compiler. True False Question 5 2 pts A statement that may be used to stop...
What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that share a set of tasks, even though the tasks are executed in different ways. Polymorphism allows a programmer to use a subclass object in place of a superclass object. Polymorphism allows a subclass to override a superclass method by providing a completely new implementation. Polymorphism allows a subclass to extend a superclass method by performing the superclass task plus some additional work. Assume that...
YOU NEED TO MODIFY THE PROJECT INCLUDED AT THE END AND USE THE INCLUDED DRIVER TO TEST YOUR CODE TO MAKE SURE IT WORK AS EXPECTED. Thanks USING PYTHON, complete the template below such that you will provide code to solve the following problem: Please write and/or extend the project5 attached at the end. You will have to do the following for this assignment: Create and complete the methods of the PriceException class. Create the processFile function. Modify the main...
Question 1 (5 points) Question 1 Unsaved What is displayed on the console when running the following program? public class Quiz2B { public static void main(String[] args) { try { System.out.println("Welcome to Java"); int i = 0; int y = 2 / i; System.out.println("Welcome to Java"); } catch (RuntimeException ex) { System.out.println("Welcome to Java"); } finally { System.out.println("End of the block"); } } } Question 1 options: The program displays Welcome to Java two times. The program displays Welcome to...
DI Question 2 1.5 pts Which situations allow the client main() in the file my_program.py to access a method name, say func(), alone, as in x-func) without dereferencing it using prepended name like modname.func or x = some object. func () or x-SomeClass.func() O func) is defined in some module, say, "modname.py" and modname is imported into my_program.py using: from modname import func() is an instance method or a class method in a class, say SomeClass, defined in the same...