TutorMe homepage

SIGN IN

Start Free Trial

Andrew C.

M.I.T Mechanical Engineering Major and Computer Science Minor

Tutor Satisfaction Guarantee

Python Programming

TutorMe

Question:

Create a python function called "translate" that takes a user input string and returns the string in the translated language. The translated language is the one I am referencing below. Any odd letter becomes a 'u' + that odd letter. So the word "Hello" becomes "Huelluo" Notice how case rules apply.

Andrew C.

Answer:

Here is the code I came up with that I will further dive into below. //// #Andrew Callahan def translate(x): odd_lower_case = ['a','c','e','g','i','k','m','o','q','s','u','w','y'] odd_upper_case = ['A','C','E','G','I','K','M','O','Q','S','U','W','Y'] translated_x = '' for letter in x: if letter in odd_lower_case: translated_x += 'u'+ letter elif letter in odd_upper_case: translated_x +='U' + letter else: translated_x += letter return translated_x print(translate(input("What do you want to be translated: "))) //// Now I will break down the individual aspects of this code. First I always start with either a written process tree or a firm written idea about how the code is to run. The way I thought is that the function takes a string input and iterates through the letters of that string. If the letter is one of the odd letters, add a 'u' out front and then that original letter (with case rules applying). Yet, if the letter is not odd just add that letter to the new string. It is important to note that the general process of this code does not use an index to directly go in and edit the original input string. This is because strings are immutable, meaning that they cannot be changed in this direct way. One must go through each letter and create an entirely new string based off the original. Also throughout this code, it is important to note that python defines strings with ' ' or " " To begin: // print(translate(input("What do you want to be translated: "))) // Even though this is the last line of my code it is the first line to be executed because it does not lie within a function. This statement is a combination of many important things. First off, the code input("What do you want to be translated: ") prints out the statement "What do you want to be translated: " and allows the user to input any string. This string is then passed as the input variable to the function translate( ). So translate("Hello") would return "Huelluo", and translate((input("What do you want to be translated: ")) will return whatever the user types in the running window. Lastly the print( ) capability displays whatever the translate( ) function returned. Remember that return and print are not the same. And so, to see the result of our user input translation we need to use the print function. // def translate(x): odd_lower_case = ['a','c','e','g','i','k','m','o','q','s','u','w','y'] odd_upper_case = ['A','C','E','G','I','K','M','O','Q','S','U','W','Y'] translated_x = '' // here I define the function using the proper syntax with x as the input variable. Only one input is required for my code. Then I define some function variables. Namely, I define the odd lower and upper case letters of the alphabet. This could have been done by using the string module and other methods, but it seems much easier and quicker to just hard-code it here. Next I defined translated_x as an empty string. This is the string which we will add letters to as we run our way through the loop to follow. // for letter in x: if letter in odd_lower_case: translated_x += 'u'+ letter elif letter in odd_upper_case: translated_x +='U' + letter else: translated_x += letter // Now comes the meat of the function. I start by defining a for loop. In this case, this loop will go through all the letters of the input string, x. It is important to note that the word 'letter' is not necessary and I could have used 'i' or 'count'. But letter seems like the most logical iterator to be more user friendly to anyone reviewing my code. And so, as the for loop iterates through each letter, I coded tests for this letter to undergo. Specifically, IF the letter is in, or better said "is an element of" the odd lower case list I defined outside the loop, THEN add a "u" and the original letter to the new translated string. But IF the letter is an element of the odd upper case list I defined outside of the loop, THEN add a "U" and the original letter to the new translated string. Notice how I use elif instead of else or if. elif allows me to have another condition that has no relation to the other if statement. else on the other hand does not allow for conditions in its line. It is merely an "if all else fails" determinate. And in my case this all else fails determinant is that if the letter is NEITHER in the odd lower or upper, case lists, THEN just add the normal letter with no 'u' preceding. // return translated_x // This piece of code simply returns the translated version of x that we created to the program. In this case this variable is automatically printed.

Calculus

TutorMe

Question:

What is the total enclosed area that the two curves, y = x^3 and y = x create between them?

Andrew C.

Answer:

A great place to start is by graphing various points for both functions. By doing this we can see that they intersect at (-1,-1), (0,0) and (1,1). The areas between them are symmetric as these are both odd functions. And so, we need only to find the area of one of these pieces and multiply it by 2 in order to get the whole picture. In this problem I will choose to do the first quadrant and then multiply the result by 2. The method to find the area between two curves is to do integral((upper function - lower function)*(dx)) with the limits going from a to b on the x-axis. In this case the limits are a = 0 and b = 1 because these are the points of intersection, anything past these and no enclosed-area is creating between the two-curves From the graph we can see that y = x is the upper function (because it lies physically further up on the y-axis) and so the integral become integral((x - x^3)*(dx)). We will come back to the limits later, but first let us compute the indefinite integral This integral is best calculated by splitting it up. What I mean by this is that the problem now becomes original integral = integral((x)*(dx)) - integral((x^3)*(dx)) Both these integrals can be computed using what I call the reverse power rule (in reference to differential calculus' power rule for taking derivatives). If you are unfamiliar with this rule it is given by integral((x^n)*(dx)) = (x^(n+1))/(n+1) + C And so, our original integral now becomes original integral = (x^2)/2 - (x^4)/4 the constant of integration is irrelevant for this problem because these functions are already well defined Now we just need to evaluate this with respect to our original limits. [(1^2)/2 - (1^4)/4 ] - [(0^2)/2 - (0^4)/4]. This results in the answer of 1/4. But remember that this was only one quadrant. Multiply this answer by 2 gives us our final answer of 1/2.

Physics

TutorMe

Question:

Bill is at an amusement park. He gets in the Whirl-O-Matic. The ride is a hollowed out, thin-walled cylinder that spins at high speeds around a central axis. As Bill gets in, he finds himself pressed to the wall as the Whirl-O-Matic spins faster and faster. So much so that the floor of the Whirl-O-Matic drops out from underneath him. a) What is the reason behind why Bill feels pressed to the wall, b)what is the minimum angular velocity, measured in radians per second, he needs to travel to keep from slipping downward. Bill has a mass of 70 kg, the radius of the Whirl-O-Matic is 4 m, gravitational acceleration is 10 m/s^2, and the coefficient of static friction between Bill and the wall is 0.7

Andrew C.

Answer:

a) Most people would say that the reason Bill is pressed to the wall is because of the centrifugal force; however, that is nothing but a fictitious force. There is no actual force pressing Bill to the wall. The feeling he feels and the reason he sticks to the wall is a result of his inertia. As the Whirl-O-Matic spins, Bill's matter desires to travel tangentially away from the Whirl-O-Matic. Yet, the walls of the Whirl-O-Matic do not travel in the straight line, instead they continuously spin around and around, blocking Bill's matter's desired path and so keeping him pressed to the wall. b) Now as with most physics problems, a great first step is a Free-Body-Diagram (FBD). (It may help to draw along). I will note our coordinate system as the positive y-direction extending upwards from Bill's head and the positive x-direction extending out from Bill's torso. Drawing an FBD of the situation yields three forces. The weight (F_g) of Bill pointing downwards (-y), the normal force (F_n) pointing axially outward (+x), and the friction force (f), keeping Bill from slipping (+y). The frictional force points in +y due to the fact that the desired motion of Bill's torso under gravity is to move downwards and friction opposes motion. And so, now with our FBD, we can see that if Bill is not to slip, but to remain in equilibrium, the frictional force pointing up (+y) and the force due to gravity pointing down (-y) have to be equal to each other. But what is the frictional force? Well the frictional force is given by Equation 1: f = (coefficient of static friction) * (normal force) The coefficient of static friction was given to us, but what is the normal force? If we recall from part a, Bill is pressing into the wall due to his inertia, and so by Newton's Third Law, the wall is pressing back into him. This is the normal force! But how can we find it? Well it important to note that any body in circular motion needs to have a radial force (F_r) keeping it in circular motion. These forces follow a certain equation derived from Newton's second law given as Equation 2: F_r = (mass)*(Radius)*(angular velocity) Ultimately, in this problem and through the FBD we can see that the normal force is in fact the radial force because it points in the radial direction constantly throughout all motion. So now that we have all the conceptual pieces in place. we are ready to combat the mathematical pieces. First we note that the variable we are solving for, angular velocity, is satisfied by solving for it in Equation 2: Equation 3: angular velocity = (F_r)/(mass*Radius) We known that F_r = F_n , but we do not have a given numerical value for F_n, and so we need another equation. This is done by referencing that f must equal F_g to keep Bill in equilibrium. It is understand that Equation 4: F_g = (mass) * (gravitation acceleration) So now setting Equation 1 and Equation 4 equal to each other and using algebra to solve for the normal force. We arrive at the equation Equation 5: F_n = (mass * gravitation acceleration) / (coefficient of static friction) Now we have a normal force which is equal to the radial force so we can plug this expression into Equation 3 to get the angular velocity. Equation 6: angular velocity = (mass * gravitation acceleration) / (coefficient of static friction * mass * Radius) Plugging in the given numerical values, one should arrive at the result that the minimum required angular velocity is 3.57 rad/sec.

Send a message explaining your

needs and Andrew will reply soon.

needs and Andrew will reply soon.

Contact Andrew

Ready now? Request a lesson.

Start Session

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 Session" 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.

Made in California

© 2019 TutorMe.com, Inc.