Question

In: Computer Science

Download Jupyter and complete your Assignment. Be sure to write and run the code separately for...

Download Jupyter and complete your Assignment. Be sure to write and run the code separately for each part. Please provide explanation for the code logic behind the code you write / design.

First part: Create Simple Student Class with constructor to get first name and last name.

Second part: Then create Address class with the constructor to get Student Address, the parameters can be , House/Apt Number, Street, Zip, State.

Third part: Modify Student Class so that it will get House/Apt Number, Street, Zip, State. and save address inside the Student as dictionary. Also implement the function in student class that print all addresses in the Student Class.

Solutions

Expert Solution

First Part:

class student: # declare class named student
def __init__(self,first_name,last_name): #define constructor with two para meters first name & last name
self.firstname=first_name
self.lastname=last_name
m=student("John","Wick") #creating object named m of student class and passes first name & last name
print(m.firstname,m.lastname) #print firstname and lastname which are attributes of object m

Output:

Second part:

class Address: #declaring class Address
def __init__(self,House_no,street_no,zip_no,state,country): #define constructor
self.houseno=House_no #constructor contains five parameters
self.street=street_no #parameters House_no,street_no,zip_no,state,country
self.zip=zip_no
self.state=state
self.country=country
n=Address("Block no.-14","Goveernment residence","360004","Gujarat","India") #creating object named n of class Address

#and passing parameter
print(n.houseno,",",n.street,",",n.zip,",",n.state,",",n.country)#print attributes of object n

Output:

Third Part:

class student:   # declare class named student

    def __init__(self,first_name,last_name): #define constructor with two para meters first name & #last name
        self.firstname=first_name
        self.lastname=last_name

    def getAddress(self,House_no,street_no,zip_no,state,country):
        #set the values in dictionary
        self.address={"Houseno":House_no,"Street":street_no,"zip":zip_no,"State":state,"Country":country}

    def show(self):    #define function to print address
        for keys in self.address:     #print values of dictionary through its  keys
            print(self.address[keys],end=",") #value seprated by comma
        print()                               #go on next line

n=student("John","Wick") #creating object from calling constructor passes first name &last name
n.getAddress("Block no.-14","Goveernment residence","360004","Gujarat","India") #calling function #getAddress() and passing parameter
n.show()       #print address of object

Output:


Related Solutions

This is an assignment for python. Download the code “ GradeBook.py ” You will be modifying...
This is an assignment for python. Download the code “ GradeBook.py ” You will be modifying the code to do the following: 1) create an empty dictionary named “FinalAverages” 2) In one for loop you will zip all lists together and get their individual members on each iteration. You can name these what ever you want. 3) on each iteration: Calculate the WEIGHTED average using the weights provided, and then add a new dictionary value to the dictionary “ FinalAverages...
public class Sum2 { // TODO - write your code below this comment. } Download the...
public class Sum2 { // TODO - write your code below this comment. } Download the Sum2.java file, and open it in jGrasp (or a text editor of your choice). This program takes two values as command-line arguments, converts them to ints via Integer.parseInt, and adds them together. Example output of this program is shown below, with the command-line arguments 3 4: Sum: 7
public class FirstChar { // TODO - write your code below this comment. } Download the...
public class FirstChar { // TODO - write your code below this comment. } Download the FirstChar.java file, and open it in jGrasp (or a text editor of your choice). This program takes a single command-line argument and prints out the first character of this argument, using String's charAt() method. If you're unsure how to pass command-line arguments to a program with jGrasp, see this tutorial. Example output of this program with the command-line argument foo is shown below: First...
Week 1 Assignment Complete this two page assignment by the end of week 1! Download and...
Week 1 Assignment Complete this two page assignment by the end of week 1! Download and open the Word document below....fill in the blank and highlight the answer to the questions or fill in the blank. Resubmit here when you're finished by adding your completed assignment as a file! BIO 212 Assignment 1.docx BIO 212 Assignment 1 Fill in the Blank: Use the table on pg. 848-853 in your textbook to help you fill in the blank. Drug Classification Action...
Download and complete this assignment by answering the questions or filling in the blanks! Week 3...
Download and complete this assignment by answering the questions or filling in the blanks! Week 3 Assignment.docx Write out what each abbreviation stands for: OTC FDA APhA DEA CSA USP PDR USP/NF LASA SR GI USAN CPOE PAD List and describe three different names by which a drug may be referred. ­­­­­­_______________________________________ ______________________________________ ______________________________________ Describe the following terms and which health care professionals can perform the tasks listed. Prescribe Administer Dispense Physicians Nurse practioners and Physician Assistants Medical Assistants Describe...
Create a new Python 3 Jupyter Notebook. At the top, be sure to name your notebook...
Create a new Python 3 Jupyter Notebook. At the top, be sure to name your notebook as "*assignment 2.08 - Your Name Here.ipynb*" (obviously, replace the "Your Name Here" part with your actual name). Create a single python cell to program the following specifications. Use what you've learned on this page to: 1. Find the index of "lmno" in the English alphabet using an appropriate instruction and store it in a variable. (hint: you'll need to define a string that...
Module 2 Programming Assignment – Battleship Refactor Refactor your Battleship drawing code from Module 1. Download...
Module 2 Programming Assignment – Battleship Refactor Refactor your Battleship drawing code from Module 1. Download the OO template for the basic battleship game, BattleshipRefactor.zip (refer below) The template has the outline of a battleship game using OO constructs. You need to add the Grid class and complete the code so that it runs correctly. At a minimum, you need to complete the Draw and DropBomb methods with code similar to the previous assignment. There will be changes due to...
PLEASE DONT FORGET TO SOLVE THE ASSIGNMENT QUESTION MOST IMP: Ex1) Download the code from the...
PLEASE DONT FORGET TO SOLVE THE ASSIGNMENT QUESTION MOST IMP: Ex1) Download the code from the theory section, you will find zipped file contains the code of Singly linked list and Doubly linked list, in addition to a class Student. In Class SignlyLinkedList, 1. There is a method display, what does this method do? 2. In class Test, and in main method, create a singly linked list objet, test the methods of the list. 3. To class Singly linked list,...
Respond to the following prompt to complete the CTE assignment. Be sure to follow the instructions...
Respond to the following prompt to complete the CTE assignment. Be sure to follow the instructions in the syllabus and your grade will be determined through the use of the related rubric (also located in the syllabus). As the Baby Boom generation continues to retire from the labor force, the ratio of retirees to workers will continue to increase. How will this demographic change impact the Social Security program? What "solution" or "solutions" would best offset the harmful effects of...
Download this file to your hard drive and follow the instructions in the Module 9 Assignment...
Download this file to your hard drive and follow the instructions in the Module 9 Assignment (Word) document. Prepare two files for your post. The first file should be a text file containing your Python solution. The second file should contain your output file(txt). Complete the following using Python on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT