Write the codes for the following exercises? ? ? ? 5.1.2 Coding Exercise 1 (External resource) (3.0
Fantastic news! We've Found the answer you've been seeking!
Question:
Write the codes for the following exercises?
?
?
?
Transcribed Image Text:
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 attribute called "storage" which defaults to 3 #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 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 33 Submit Run Grades Reset Console output will be displayed here 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 attribute called "storage" which defaults to 3 #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 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 33 Submit Run Grades Reset Console output will be displayed here
Expert Answer:
Answer rating: 100% (QA)
Find the python codes below 512 Phonepy class Phone def initself selfstorage 128 s... View the full answer
Related Book For
Business Statistics in Practice
ISBN: 978-0077404741
6th edition
Authors: Bruce Bowerman, Richard O'Connell
Posted Date:
Students also viewed these computer network questions
-
1. Write a class called Student. This student class should have the following fields: Id: This is the Id of the student. -_scores: This is a list of scores that belong to the student. Add the...
-
Create a class called Heater, that contains four fields, temperature, increment, max and min, all of whose type is double. Make sure you write a description of your new Class in the comments, with...
-
In this exercise we consider how to deal with class lengths that are unequal (and with open-ended classes) when setting up histograms. Often data are published in this form and we wish to construct a...
-
The Apache NetBeans IDE is mainly composed of NetBeans Open-Source IDE and NetBeans Platform. (True/False)
-
What is retained earnings? What items increase the balance in retained earnings? What items decrease the balance in retained earnings?
-
Explain the difference between the AE curve and the AD curve.
-
Assign state numbers to the states in the traffic light example of Exercise B.41 and use the tables of Exercise B.42 to write a set of logic equations for each of the outputs, including the...
-
Freezing of a spherical drop (Figure 11B.10) to evaluate the performance of an atomizing nozzle, it is proposed to atomize a nonvolatile liquid wax into a stream of cool air. The atomized wax...
-
Which is NOT an acceptable method of disposing of variances? a.closing them to work-in-process, finished goods, and cost of goods sold b.closing them to raw materials, work-in-process, and finished...
-
Read Case 14-1 Trojan Technologies (15th ed., p. 426 OR 16th ed., p. 431) Guiding Questions and additional information: In preparing your case study, ensure that you answer the following questions:...
-
Which of the following is a problem for a free market economy? Group of answer choices Very few economic choices Big gap between the poor and the wealthy No economic freedom Not enough competition...
-
Hey i need the following pages done ASAP.Please and thank you D2L Lesson 1: Electrostatics - Physics X L1Electrostatics X Course Hero +...
-
Bed & Bath, a retailing company, has two departmentsHardware and Linens. The companys most recent monthly contribution format income statement follows: Department Total Hardware Linens Sales $...
-
Use the formula g'(a) = lim. [(g(x)-g(a) )/ (x-a) ] x-->a to find g'(x) for g(x) = srqrt(x+7). Find the equation fo the tangrnt line to g(x) at x =-5
-
As shown in the figure below, an incompressible liquid flows steadily and vertically upward in a circular cross-sectional pipe. At section (1), the velocity profile over the cross-sectional area is...
-
writE a paper on teamwork 1. Share an experience with working on teamwork during your academic journey or on the job. 2. Share both positive and negative experiences. 3. What are your suggestions...
-
Question 7 Not yet answered Flag question Camilla is getting a 3 0 - year loan for a $ 3 6 0 , 0 0 0 home with 1 0 % down and an interest rate of 5 % . Her monthly taxes are $ 3 0 0 and her monthly...
-
The Pletcher Transportation Company uses a responsibility reporting system to measure the performance of its three investment centers: Planes, Taxis, and Limos. Segment performance is measured using...
-
Set up probability revision tables to a. Find the probability that the "economist says up" and rind the posterior probabilities of market up. market flat, and market down given that the "economist...
-
Consider Exercise 4.14 (page 170). Using the results in Table 4.4 (page 171), estimate the probability that a randomly selected 21- to 49-year-old consumer would a. Give the phrase a rating of 4 or 5...
-
a. Construct a relative frequency distribution and a percent frequency distribution for the bottle design ratings. b. Construct a cumulative frequency distribution and a cumulative percent frequency...
-
Explain what information is conveyed by the value of the standard error of the slope estimate.
-
Which values of the slope parameter indicate that no linear relationship exist between the predictor and response variables? Explain how this works.
-
Where would a data point be situated that has the smallest possible leverage?
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App