variables - Python raw_input into dictionary declared in a class -


I'm incredibly new to Python and I really need to be able to do this job. I want to ask the user through raw_input what is the module and the grade and then it has been put in the grade in the student's class already defined in the dictionary. I do not know what to do! thank you in advanced!

  students = [] # All student objects (database) def print menu (): Print "------ Main Menu ------ \ N" "1. A Add Students \ n "" 2. Print All Students \ n "" 3. Remove Students \ n "" -------------------- - \ n "Classroom Student: First name = "" last name = "age = 0 studentID =" "degree =" "grade = {" module name ":" "," grade ":" "} def setfirst_name (self, first name) : Self.firstName = firstname def defFirstName (self): back to self First name DRF setLlastName (self, last name): self.lastName = lastName def getLastName (self): return self. Unknown Df set degree (self, degree): self. Degree = degree def getDegree (self): return self Def defredGrades (self, grade): self.grades = grade def getGrades (self): return self Grade def set StudentID (self, studentid): self.studentid = studentid def getStudentID (self): return self. STANDARD DRT SETGE (Self, Age): Self. Jij = era df mill edge (self): returns self GEF Adustant (): Calculation = 0 First name = RAW_Input ("Please enter the student's first name:") lastName = Raw_input ("Please enter the student's last name:") degree = raw_input ("Please enter the student's degree:" ), While counting! = -1: student.grades = raw_input ("Please enter the module name of the student:") # Student "grade" = student () # Make a new student object student.setFirstName (first name) # This student's first name student Settlement Name (Last Name) Student.Credit Degree (Degree) Students .customs (grades) students. Session student student (student) Students SetAge (age) students.append (student) # Add this student to the database  

Some things:

  1. Start the properties of your class in a __init __ method:

  2. Jeffrey says get rid of all the gates and the setters.

  3. Use the module names as key and grade values:

Some code snippets:

def __init __ (self, first name, last name, age, student ID, degree): self.firstName = firstName self.lastName = lastName ... self.grades = {} < / Pre>

and:

  while true: module_name = raw_input ("Please enter student module name:") If not then module_name: break grade = raw_input ("please% s Enter the grade for: "% Module_name" student. Grade [module_name] = grade  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -