Q: 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
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 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
Step by Step Solution
3.46 Rating (149 Votes )
There are 3 Steps involved in it
Step: 1
Find the python codes below 512 Phonepy class Phone def initself selfstorage 128 s... View full answer

Get a step-by-step solution from a verified subject matter expert – not AI-generated answers
Step: 2Unlock detailed examples and clear explanations to master concepts

Step: 3Unlock to practice, ask and learn with real-world examples

See step-by-step solutions with expert insights and AI powered tools for academic success
-
Access 30 Million+ textbook solutions.
-
Ask unlimited questions from AI Tutors.
-
24/7 Expert guidance tailored to your subject.
-
Order free textbooks.
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started
Study Smart with AI Flashcards
Access a vast library of flashcards, create your own, and experience a game-changing transformation in how you learn and retain knowledge
Explore Flashcards