Question: Hi, I have a question about Python. I don't have any experience in Python as I've only really ever coded in mostly C++ or C,

Hi, I have a question about Python. I don't have any experience in Python as I've only really ever coded in mostly C++ or C, and I'm confused about how to read a string from a printed statement. For example, if I print out a statement as follows: print(Home = + getHome(car, 45, mercedes)), I understand that this would call on the function getHome and do whatever that function tells the program to do. My question is, what do I do to be able to read those three words within the brackets and print out what is needed. Like for above, how would I be able to "read" that there is car in between the first quotations (anything can go in between these parentheses so how would i read the word in there), the numbers after the comma, and then the word within the next quotations. Here is an example using the above statement with a sort of psuedocode:

print(Home = + getHome(car, 45, mercedes))

def getHome

read the words and numbers within the parentheses

if (first word = car)

{

print("statement")

}

else if (second number > 40 || < 60)

{

print("statement")

}

else if (third word = mercedes)

{

print("statement")

}

I don't need an exact code or anything that needs to run, I more just want an explanation on how to read those statements and print out what is needed accordingly. I will be sure to rate if I find the answer helpful. Thank you!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!