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.

% 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.

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.

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