Phone.py 1 #Write a class named Phone. The Phone class should 2 #have an attribute called...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Phone.py 1 #Write a class named "Phone". The Phone class should 2 #have an attribute called "storage" which defaults to #128, and an attribute called "color" which defaults 4 #to "red". 5 # 6 #Hint: 'attribute' is another common word for 7 #'instance variable'. 8 9 10 #Write your class here! 11 12 13 14 #Below are some lines of code that will test your function. 15 # You can change the value of the variable(s) to test your 16 #function with different inputs. 17 # 18 #If your function works correctly, this will originally 19 #print 128 and red, each on a separate line. 20 new_phone= Phone () 21 print (new_phone.storage) 22 print (new_phone.color) 23 24 25 Submit Run Grades Reset Console output will be displayed here 5.1.2 Coding Exercise 2 (External resource) (3.0 points possible) Number.py 1 # Write a class named "Number" with one attribute called 2 #"value" which defaults to 0 and another attribute called 3 #"even" which defaults to True. 4 # 5 #Next, create an instance of this class and assign it to 6 #a variable called "number_instance". 7 # 8 #Then, set the value attribute to 101 and the even 9 #attribute to False. 10 11 12 #Write your code here! 13 14 15 # Note that this exercise does not print anything by 16 #default. You're welcome to add print statements to debug 17 #your code when running it. Note that the autograder 18 #will check both your value for number_instance and your 19 #definition of the class Number. 20 21 22 Submit Run Grades Reset Console output will be displayed here 5.1.4 Coding Exercise 1 (External resource) (3.0 points possible) Number.py 1 #Rewrite the "Number" class from 5.1.2 Coding Exercise 2. 2 # This time, however, require arguments for value and 3 #even in the constructor. Then, inside the constructor, 4 #create new instance variables called value and even that 5 #copy the values of the arguments passed into the 6 #constructor. 7 # 8 # In other words, rewrite the Number class such that value 9 #and even behave the way studentName and enrolled behaved 10 #in the exercise above, and the way firstname and lastname 11 #behaved in video 5.1.4.1. 12 # 13 #Then, as before, create an instance of this class and 14 #assign it to a variable called "number_instance". value 15 #should again be set to 101 and even should be set to 16 #False. 17 # 18 #Hint: Remember, the way you initialize the instance will 19 #have to change, too, based on the changes to the 20 #constructor that we're requiring. 21 22 23 # Write your code here! 24 25 26 #Note that this exercise does not print anything by 27 #default. You're welcome to add print statements to debug 28 #your code when running it. Note that the autograder 29 #will check both your value for number_instance and your 30 #definition of the class Number. 31 32 33 Submit Run Grades Reset Console output will be displayed here Phone.py 1 #Write a class named "Phone". The Phone class should 2 #have an attribute called "storage" which defaults to #128, and an attribute called "color" which defaults 4 #to "red". 5 # 6 #Hint: 'attribute' is another common word for 7 #'instance variable'. 8 9 10 #Write your class here! 11 12 13 14 #Below are some lines of code that will test your function. 15 # You can change the value of the variable(s) to test your 16 #function with different inputs. 17 # 18 #If your function works correctly, this will originally 19 #print 128 and red, each on a separate line. 20 new_phone= Phone () 21 print (new_phone.storage) 22 print (new_phone.color) 23 24 25 Submit Run Grades Reset Console output will be displayed here 5.1.2 Coding Exercise 2 (External resource) (3.0 points possible) Number.py 1 # Write a class named "Number" with one attribute called 2 #"value" which defaults to 0 and another attribute called 3 #"even" which defaults to True. 4 # 5 #Next, create an instance of this class and assign it to 6 #a variable called "number_instance". 7 # 8 #Then, set the value attribute to 101 and the even 9 #attribute to False. 10 11 12 #Write your code here! 13 14 15 # Note that this exercise does not print anything by 16 #default. You're welcome to add print statements to debug 17 #your code when running it. Note that the autograder 18 #will check both your value for number_instance and your 19 #definition of the class Number. 20 21 22 Submit Run Grades Reset Console output will be displayed here 5.1.4 Coding Exercise 1 (External resource) (3.0 points possible) Number.py 1 #Rewrite the "Number" class from 5.1.2 Coding Exercise 2. 2 # This time, however, require arguments for value and 3 #even in the constructor. Then, inside the constructor, 4 #create new instance variables called value and even that 5 #copy the values of the arguments passed into the 6 #constructor. 7 # 8 # In other words, rewrite the Number class such that value 9 #and even behave the way studentName and enrolled behaved 10 #in the exercise above, and the way firstname and lastname 11 #behaved in video 5.1.4.1. 12 # 13 #Then, as before, create an instance of this class and 14 #assign it to a variable called "number_instance". value 15 #should again be set to 101 and even should be set to 16 #False. 17 # 18 #Hint: Remember, the way you initialize the instance will 19 #have to change, too, based on the changes to the 20 #constructor that we're requiring. 21 22 23 # Write your code here! 24 25 26 #Note that this exercise does not print anything by 27 #default. You're welcome to add print statements to debug 28 #your code when running it. Note that the autograder 29 #will check both your value for number_instance and your 30 #definition of the class Number. 31 32 33 Submit Run Grades Reset Console output will be displayed here
Expert Answer:
Related Book For
Computer Organization and Design The Hardware Software Interface
ISBN: 978-0124077263
5th edition
Authors: David A. Patterson, John L. Hennessy
Posted Date:
Students also viewed these accounting questions
-
Write the codes for the following exercises? ? ? ? 5.1.2 Coding Exercise 1 (External resource) (3.0 points possible) Phone.py 1 # Write a class named "Phone". The Phone class should 2 #have an...
-
Economies of scale in production arise from, among others: A. increased specialization. B. the apportionment of initial/fixed production costs. C. the best coordination that always results from...
-
In class, we discussed the abstract data structure Stack. A stack is a collection of items where items are added to and removed from the top (LIFO). Use the Node class (an object with a data field...
-
B. Giulia runs at 4.5 m/s (1 m/s is 2.2 mi/h ... just think "about 2 mi/h"). She is running eastward into the sunrise and along a straight-line path. Show a complete sketch from when you start...
-
D-(+)-Mannose can be reduced with sodium borohydride to form D-mannitol. When D-mannitol is dissolved in acetone containing a trace amount of acid and the product of this reaction subsequently...
-
What are two differences between IFRS and U.S. GAAP with respect to the classification of financial statement items?
-
Explain the difference between Inverse ETFs and Leverage ETFs.
-
A Wheatstone bridge is type of bridge circuit used to make measurements of resistance. The unknown resistance to be measured, Rx, is placed in the circuit with accurately known resistances R1, R2,...
-
2. Another dielectrics-filled spherical capacitor Given a spherical capacitor with dielectrics in between for two different cases below, find the net capacitance of the spherical capacitor for both...
-
Today, Feb 14th, 2021, I have collected the following from Bloomberg: The spot rate: USD 1.21/EUR 2-year USD YTM=0.11% 2-year EUR YTM=-0.72%. Note: YTM is always quoted per year. if we want to make...
-
When Larry was in sixth grade, he was caught cheating on a test. Even though he learned his lesson and vowed never to cheat again, he gained a reputation among the teachers as a "bad student" and was...
-
What phrases can a chef supervisor use to encourage the kitchen team? How could a foodservice operation use diversity as a competitive advantage? Why is management of diversity vital? Is this a...
-
1. What is an idea assessment? 2. Explain the process of conducting an idea assessment. 3. Explain why it is necessary to conduct a feasibility analysis. 4. Describe the four components of a...
-
Look at the credits of three DVDs. Copy the wording used in crediting various contributors. Look at several different web sites. Do they list credits? Why or why not?
-
A 67-year-old man experienced sudden loss of vision in the left eye 3 hours ago. You record visual acuity as OD 20/20 and OS no light perception. The right pupil responds to light directly but not...
-
Index Numbers are economic barometersExplain Discuss the different steps that have to be taken in the construction of a price index number. What are index number? How do you choose the base year for...
-
What force ( in N ) must be applied to a 1 5 0 . 0 kg crate on a frictionless plane inclined at 3 0 degree to cause an acceleration of 6 . 5 m / s 2 up the plane?
-
In July 2013, cnet.com listed the battery life (in hours) and luminous intensity (i. e., screen brightness, in cd/m2) for a sample of tablet computers. We want to know if screen brightness is...
-
A systolic array is an example of an MISD machine. A systolic array is a pipeline network or wavefront of data processing elements. Each of these elements does not need a program counter since...
-
Give an algorithm for constructing the sum-of-products representation for an arbitrary logic equation consisting of AND, OR, and NOT. The algorithm should be recursive and should not construct the...
-
Assume that for a given program 70% of the executed instructions are arithmetic, 10% are load/store, and 20% are branch. 1. Given this instruction mix and the assumption that an arithmetic...
-
Wallace and Hussain type estimators for the variance components of a one-way unbalanced panel data model. (a) Verify the \(E\left(\widehat{q}_{1} ight)\) and \(E\left(\widehat{q}_{2} ight)\)...
-
Using the Monte Carlo setup for the unbalanced one-way error component model considered by Baltagi and Chang (1994), compare the various estimators of the variance components and the regression...
-
Using the Harrison and Rubinfeld (1978) data published in Belsley, Kuh and Welsch (1980) and provided on the Springer website as Hedonic.xls, reproduce Table 9.1. Perform the Hausman test based on...
Study smarter with the SolutionInn App