Enable contrast version

# Tutor profile: Sarah G.

Sarah G.
BA in political science with a passion for sustainability and data

## Questions

### Subject:Python Programming

TutorMe
Question:

Write a code snippet that prompts the user for a number and then calculates the factorial of that number. Include error-checking so that the user cannot enter a negative number.

Sarah G.

run = 1 while run==1: print("Please enter a value to find the factorial of, ex. 7") num = int(input()) if num< 0: print("This is not a valid input, please enter a positive number.") elif num == 0: print("The factorial of this number is 0") run= run + 1 else: factorial = 1 for F in range(1,num+1): factorial= factorial * F print("The factorial of this number is",factorial) run = run+1 This simple program has a while loop and a series of if/else/elif statements to take user input and then check if it fits the specified parameters. The inclusion of error checking helps make this a successful program as it anticipates error on the part of the user and avoids returning the wrong factorial. The for loop at the bottom also illustrates the "in range" syntax that python uses.

### Subject:Writing

TutorMe
Question:

Do you need 5 paragraphs in an essay? What are the structural elements you need to include in a good essay?

Sarah G.

### Subject:C Programming

TutorMe
Question:

Write the code to cycle through and print out an array of integers a[N] (array "a' with length = N) using pointers rather than indices.

Sarah G.

for (int *p = a; p < a+N; p++){ // cycles through the array with pointers printf("%d ", *p); // prints the integer at that spot in memory, %d tells the computer to interpret the data as an int. } Here, *p is the pointer that we use to cycle through the array. This code takes advantage of the fact that C stores arrays in consecutive spaces in memory. What we are doing here is moving through those slots in memory rather than moving through the indices of the array as we might do in other languages.

## 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