Python Forum
Problem with writing an objective oriented python assignment
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with writing an objective oriented python assignment
#1
Can someone help me while writing an assignment?

It is necessary to create a template for creating objects of the Student type. Each Student should have the following properties: It is necessary to create a template for creating objects of type Student. Every student should have the following characteristics: name, address, phone, course, index_number.

Each object that represents a student should have the following behavior (method): getInfo()

It is necessary that the getInfo() method prints data about one student (for example Name: John Benson, address: High Park 36, Phone: (507) 833-3567, Course: Geography, Index number: 123/007).

To implement templates for creating objects, use the class.

Finally, on the basis of the created template, it is necessary to create three objects representing three students with data as desired. Above the three created objects, it is necessary to call the method for printing data - getInfo() and display the information with the print command.


I hope that someone can help me with writing this assignment, since I tried but honestly it didn't work.
I would need an assignment written in python.
Thanks in advance for all the effort and help. Smile
Reply
#2
https://python-forum.io/misc.php?action=help&hid=52 Wrote:Homework and No Effort Questions

This forum is focused on education. It exists to help people learn Python. We don’t exist to solve others’ problems, although that tends to be a happy byproduct of education. You should keep this in mind when writing replies.

It is highly advised that you do not post the full solution, even if the asker is putting in the effort. It is better to use hints with natural language rather than code if at all possible. Only after the author has something complete you may go all out.
buran likes this post
Reply
#3
Hi,

Quote: I hope that someone can help me with writing this assignment, since I tried but honestly it didn't work.
Please show what you tried, even if it didn't work. Having a starting point and see what's to improve on your code is way better than starting from scratch.

Regards, noisefloor
Reply
#4
To get you started:
1. Define the class (e.g. class Student)
2. Define the elements of the class (name, address, etc)
3. Define the get_info() function to print the student information from the current class
4. Write the main code that uses this class to define several students and use get_info() to print the information back.

When you have trouble, tell us which step you are stuck at and what you have done.
swassilis likes this post
Reply
#5
Proceed as user jefsummers specified

The syntax for defining classes in python is:
                                                 class Name(object):
                                                     
                                                      # In python all classes are subclasses of a general class object
                                                      #  therefore the "(object)" syntax in the declaration.
                                                      # In order to create  objects of your class you declare
                                                      # an initialize method. 
                                                      # you can specify attributes of your object either by setting to a default value
                                                      # when initializing(creating) the object or passing them as arguments
                                                      def __init__(self,arg_1,arg_2) :
                                                              self.text = "This is an object of class Name"; # default attribute value
                                                              self.color = arg_1; # attribute value is passed by the user 
                                                              self.size = arg_2; # same as above
                                                             

                                                       # Then define extra methods(functions) in your class
                                                       def method_1(self):
                                                                # methodcode

                                                       def method_2(self,arg):
                                                                # methodcode
#Creating an object of your class
   myobj = Name("green",4) # Creates myobj by applying __init__   to the arguments ""green
                                        #  and 4.
# Accessing an attribute of your object
   myobject.color # which in this case is the string "green"
# Methods(classfunctions) are applied to your object in the following manner
   myobj.method_1(); #First method without extra arguments
   myobj.method_2(x);  # Second method takes extra argument x when called.
Remember to do the intendation of your code correctly

-Which code belongs to the class declaration
-Which code belongs to the methods
Reply
#6
Good. Recommend that you use a copy of the database for your development work in case you accidentally damage/erase it. It happens.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python for Everybody 5.2 assignment baba04201 20 173,240 Jul-25-2023, 04:15 PM
Last Post: MicaelSchutz
  Python for Everybody 3.1 assignment ramadan2099 18 45,378 Jan-23-2021, 06:27 AM
Last Post: KonohaHokage
  Coursera python for everybody 5.2 assignment SteppentigerV2 11 12,814 Oct-22-2020, 11:57 AM
Last Post: Larz60+
  [split] Python for Everybody 5.2 assignment ramadan2099 3 12,039 Jul-15-2020, 04:54 PM
Last Post: Bipasha
  Python Assignment 3 - Applied Data Science - 2.3 eyavuz21 8 4,943 Jun-06-2020, 08:59 AM
Last Post: eyavuz21
  Python Password Saver Assignment sshellzr21 2 6,146 May-02-2020, 01:34 AM
Last Post: sshellzr21
  Python for Everybody 3.3 assignment ramadan2099 7 31,729 Apr-08-2020, 06:49 AM
Last Post: DeaD_EyE
  Python for everyone course assignment 5.2 ofekx 3 8,527 Dec-23-2019, 08:41 PM
Last Post: nilamo
  [split] Python for Everybody 5.2 assignment jonchanzw 4 8,455 Oct-22-2019, 08:08 AM
Last Post: perfringo
  Python Assignment 5.2 amos76823 3 15,963 Jan-17-2019, 07:34 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020