00:02
Okay, so this question asks us to write a program that asks for a user's name, page, and favorite color print a welcome message in python.
00:17
This is what i assume, a very entry -level question, so i will assume very little prior knowledge in python.
00:25
Most python ids will have a similar layout where usually at the bottom there's a problem, there's a place like a terminal or console where you can have the output of your program, a place to write code, and a file explorer on the left.
00:47
We're going to create a new file, a new python file, and we're going to name it welcome message with no extension, always avoid using spaces, always separate word, with a dash or just write welcome and message with a capital letter.
01:17
Whitespace are usually not recommended.
01:21
We have a welcome message file so it's a dot pi file that we can see here and if i go on if i do a right click and i press run welcome message it will run my welcome message and as you can see it did process finish with exit code zero which is the standard output for a program that does nothing since we asked nothing we did nothing it's an empty file it's normal to return nothing to output things on this screen we will use the print function so it's a default function in python and whatever we write here will be printed in the console at the bottom if i say hello and i run again right click run welcome message it will i put hello so this is the first step now we would like to add a name to the name of the user we're going to put this on line 2 and we're going to have user name so that would be the the name of the variable we got to store the username in a variable we're going to use the input function which is also standard in python we're going to ask a question which is what your name so if i run my program run welcome message it asks me what's my name and if i write for example tom it will just say hello but it doesn't say hello tom we're going to improve on this so what's your name we're going to add this backslash and because i don't want to write right after the question mark i want to write on a new line this backslash and means a line return it means we will start writing on the line under i want to write hello and username.
03:53
So if i right click, run welcome message and i write, what's your name and i write for example, john, says hello john, but it says hello john in one word.
04:07
We need to add a space here so that it's a bit more readable.
04:14
What's your name? i write alice, hello alice.
04:21
So that's great, that's a good start.
04:23
We can even add an exclamation mark like this.
04:31
Now we want to know the user's age, so we can ask user age...