Exercise: A patient named John Smith

Hi, I’ve been following both the course (Complete Python Mastery) and the yt tutorials on Python (for beginners).

One thing I did’t get is an exercise that appears during the yt tutorial (I mean: Python Tutorial - Python for Beginners [Full Course] at minute 17:24).

Here, after explaining the variables, Mosh gives us this little exercise to do:

“We check in a patient named John Smith. He’s 20 years old and he’s a new patient”.
We have to define three variables, one for his name, one for his age and the last one to tell if it’s a new or an existing patient.

The given solution is:

full_name = “John Smith”
age = 20
is_new = True

How would it look if we wanted to run it and see the result?
Because what I wrote is:

name = “John Smith”
age = “20”
length_of_stay = “new patient”
print(name + " is " + age + ". " + "He’s a " + length_of_stay)

I had to use all three as a string because otherwise it would be considered as a mistake.
Can someone explain? Please.

Hey @Lux not that i’m a Pro or anything of that kind i happen to be a fellow python course student but i really suggest you store your data a ‘dictionary’ rather than a ‘variable’ that way you can call out your input.

1 Like

I’ll look it up. Thank you!

1 Like

Hi, I’ve seen this exercise in Mosh Youtube video as well.
I would say that the video is only touching on the surface part of coding.
I have bought the Python Mastery a week ago and I am now able to finish this exercise myself based on what I’ve learned from the course.

If you had the opportunity, I would suggest you to go for the course.
You would have finish this exercise by utilizing the first 3 chapters.

If you would like the answers, please message me. :slight_smile: