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)
-
Explain why the aggregate demand curve represents a series of equilibria.
-
When can a taxpayer use the standard mileage rate? Is the standard mileage rate better than the actual auto costs?
-
What are some examples of experiential retail that are likely to appeal to younger shoppers in their late teens and early 20s?
-
Identify the feasible region for the following set of constraints: 3A - 2B 0 2A - 1B 200 1A 150 A, B 0
-
A company sold 5,600 units of its only product and reported the following contribution margin income statement for this year. Contribution Margin Income Statement For Year Ended December 31 Sales...
-
To answer this question, you must obtain data from the Bureau of Economic Analysis (BEA), http://www.bea.gov, on the U.S. balance of payment (BOP) tables. Go to interactive tables to obtain annual...
-
Is ethyl chloride have a higher molecular dipole moment than ethyl iodide? Explain your reasoning.
-
Many companies get involved in environmental, or green, issues to demonstrate their social responsibility. How might a company align its social responsibility efforts with its strategy? Provide...
-
Globalization and increased cross-cultural business bring moral issues and competitiveness front and center today. Why is it important for companies to take a position on social issues and build a...
-
Why is it important for firms to do business with integrity and earn the publics trust in international business today?
-
How are risk and return each defined? Do you think there is a relationship between them?
-
Define relevant range. Why is it important?
-
Analyze the factors that categorize Amazon as an ambidextrous organization. Your analysis is to include Amazon's: Overall organizational structure Exploitation units o Exploration Units Collaboration...
-
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...
-
Which of the following taxpayers is engaged in a specified service trade or business? (a) A lawyer (b) An architect (c) A professional soccer player (d) A freelance writer who publishes articles and...
-
D, a single taxpayer, holds a 25% ownership interest in an LLC that operates a department store. Ds allocable share of net operating income from the LLC is \($100,000\) for the year. D also works...
-
A and B form the AB equal general partnership. A contributes \($10,000\) cash and a depreciable asset with an adjusted basis of \($40,000\) and a fair market value of \($90,000.\) B contributes...
Study smarter with the SolutionInn App