Enable contrast version

Tutor profile: Janet L.

Inactive
Janet L.
Currently a Software Engineer but Tutor for 3 Years
Tutor Satisfaction Guarantee

Questions

Subject: Python Programming

TutorMe
Question:

Can you explain to me how the '%' operator works in Python?

Inactive
Janet L.
Answer:

% is the arithmetic operator symbol for modulus. A way to think of this logic is calculating the remainder from a long division equation. % is the remaining value from dividing two numbers. In order to calculate 7 % 2, I would need to find out how many times 2 goes into 7 evenly or another way to think is divide 7 by 2. Then, calculate the remaining value. 2 goes into 7, 3 times evenly producing 6. 7 - 6 = 1. 1 is the % value. 7 is divisible by 2, giving 3 times fully ==> 6 with a remainder of 1. 1 is the % value.

Subject: Javascript Programming

TutorMe
Question:

How can you see the type of a variable?

Inactive
Janet L.
Answer:

There is a "typeof" operator that when used, returns the type of the value given.

Subject: C++ Programming

TutorMe
Question:

Can local and global variables have the same name? If so, how can you differentiate which variable you want to access within a defined function?

Inactive
Janet L.
Answer:

Global variables are created so they can be accessed anywhere within the code. Local variables are specific to a the scope of where they are defined. Because they are accessed in different places, yes they can have the same names. However the syntax for accessing their individual values are specific. For example, if you have: int x = 10; int main(){ int x = 2; } the 'x' value defined outside int main() function is a global variable and the 'x' defined within int main() is a local variable. The compiler gives preference to a local variable so if a: cout << "value of x:" << x << endl; were executed then the printed out value of 'x' would be 2, as that is the value of local variable x. In order to access the global variable 'x's value of 10, we need to use the "scope resolution operator ( :: )" If: cout << "value of Global x:" << ::x << endl; cout << "value of Local x:" << x << endl; were executed, then we would see see Global x as 10 and Local x as 2.

Contact tutor

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

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.