I think you need to look into string concatenation, the easiest and best of which is f strings. You could do something like;
print(f'welcome, {nam}')
You could also "add" the strings together.
print('welcome, ' + nam)
Another thing, when assigning the output of something to a variable, you can think of it as "the result of the code right of the equals sign is the value of the variable".
The input function assumes that the value should be interpreted as a string, but what if want it to be a number? You can just wrap another function around your input
user_number = int(input('what's the number?'))
Yup. You'll see functions wrapped inside other functions all the time. The function on the inside will run first, then the next, etc.
In the example I gave, the value of nam is a string. But it you need to perform some mathematical function to it, it needs to be interpreted as a number. So once the value is received, int() will convert it into a number. Finally, that final value will be assigned to nam. Wrapping functions inside of functions is a great way to write concise code.