Lesson one- Use of print and paranthesis

I just started learning to code.
I am struggling in understanding the use of simple “=” with variables and print(“xxx”)

I just finished this exercise and a
after trying about 5 times i got it correct but not sure why.
Here is what the lesson asked for and what i had.

print(“xx”) is a function.
What it does, more or less, is take what you’ve put inside the brackets and prints it out to the screen.
For stuff inside quotes, it’ll print as is.
If there’s no quotes, it’ll print the value of the variable.
so, using your code;
would print;

would print;

So, for your line 3.
the print(“hello”) will print hello to the screen.
But it wont alter the value of greeting. You’ll encounter functions soon enough which do ‘return’ a value, but print is only concerned with putting stuff on screen.

So, to alter your code;
greeting = “hello”
name = “arlet”

This would assign the string values to those two variables.
Then, you could do this;
greeting_with_name = greeting + name

This means greeting_with_name would become the value of greeting - which is “hello” - and add the value of name - which is “arlet” - on to the end of it.
So, greeting_with_name would now hold the value;
and using
would now print that value to the screen.

There’s, as always seems the case, a little more to it than that that you’ll get to in due course, but hopefully that’s helped a little.
You could have a play around and see if you get the results you expect.

Have fun


Thank you! it seems i struggle a lot with variables and defining them

Try not to worry too much. Starting out there seems like a lot of stuff to get your head round. It can be the hardest part because everything is so new and alien.

Take your time and be patient, I’m sure you’ll get there.

1 Like