0 of 5 questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Your time:
Time has elapsed
Good work attempting the practice problems!
Please leave a comment below if you require any clarifications or send an email to [email protected] if you have any comments about this quiz.
You have completed this lesson!
Write a python program to show the creation of a constructor with in a class?
Hint: Create a class that defines an __init__() method.
Remember, the __init__() method is called as a constructor of the class.
This response will be reviewed and graded after submission.
Write a python program to show the creation of a parameterized constructor?
Once you’ve added a parameterized constructor how do you create an instance of this class? Is it possible to create an instance without passing a parameter?
This response will be reviewed and graded after submission.
Write a Python class to implement pow(x, n)? (x to the power of n)
In other words, write a class that has an attribute x.
1) Your class should be able to handle two different scenarios. It should allow creation of instances (objects) in two ways –
2) Your class should have a method “pow” that will take two integers (x and n) as inputs and return back the value of x ** n (power).
This response will be reviewed and graded after submission.
You have a friend who goes to school. His parents want you to store his marks of 4 subjects and the teacher’s suggestion comment for each exam (totally 3 comments). How can you store all these different variables in an easy manner? Write a program that does this.
Your friend’s parents want you to print all the data onto the screen. Add a function that prints all this data as well.
What happens if you solve this problem without using classes? How would you solve this without classes? Do classes provide you any advantage when it comes to storing all this data?
This response will be reviewed and graded after submission.
Use the class that you created in the previous problem. Now try to add the marks and comments for 5 (or more) different students. You must also store the name now and display it along with the other data. So modify the class to include name as well.
Do you feel that classes are easy to use in situations where you have lots of variables that are “related” to each other much like the real world? Imagine solving this without classes for a minute. Can you count how many variables you would have created? How messy it would have been to keep all data that is related to each other in sync?
This response will be reviewed and graded after submission.