Enable contrast version

Tutor profile: Gavin C.

Inactive
Gavin C.
Junior Embedded Developer and Tutor for 3 years
Tutor Satisfaction Guarantee

Questions

Subject: Python Programming

TutorMe
Question:

How would one create an idempotent object in the Python programming language. What are "magic methods"?

Inactive
Gavin C.
Answer:

To create an idempotent object in python overwrite the current self.__dict__ attribute of each initialized object with a global dictionary containing the objects attributes. The global object will be the same memory location for each new object instance and the self.__dict__ field is the attribute data for that current instance. By setting the current, local data to the global shared data, each new instantiation will simply be set to the same underlying application data, making them effectively a singe object. Magic methods are implicit functions implemented for each python class. Much like the __dict__ attribute of a class, they are inherited functions which implement all system functions by python such as addition, subtraction, dictionary retrievals, and length calculations.

Subject: C Programming

TutorMe
Question:

How would you create an idempotent object in C and in what cases might such a thing be useful?

Inactive
Gavin C.
Answer:

An idempotent object means there is only one such instance of that object in the program or system. One way to create such an object is specifying a physical memory location in the object initialization and maintaining a flag if that object has been created. That memory location will be constant through all programs irregardless of the context call, and will contain the exact same data. The flag will help us ensure that we do not reinitialize the object a second time and write over data. Such an object is useful in creating semaphores or mutexes where it is important to maintain constant access to a single object across multiple programs.

Subject: Assembly Language

TutorMe
Question:

Write a program in MIPS assembly to load the next value in an array of 32-bit integers starting at the memory address pointed to by register 3, into register 1. Assume you are woking on a byte addressable machine.

Inactive
Gavin C.
Answer:

ADDI R3, 4, R4 #move memory address one integer over in memory LDR R1, R3 #load value at memory address into register 1

Contact tutor

Send a message explaining your
needs and Gavin will reply soon.
Contact Gavin

Request lesson

Ready now? Request a lesson.
Start Lesson

FAQs

What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Lesson" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.
BEST IN CLASS SINCE 2015
TutorMe homepage
Made in California by Zovio
© 2020 TutorMe, LLC
High Contrast Mode
On
Off