Posts

Showing posts with the label variable

Using Variables

Image
In the last post, we saw how to print Hello World using the print() command. Now suppose you want to print your name with Hello World. Sounds interesting. But for that, you have to save your name at some location, that is where variables are used. Lets see an example : As you can see, 'anyname' is a variable used to take input from user. The input() command is used to take input from user. The user inputs his/her name and it is stored in 'anyname' Next is printing the name. So, in print() command, you can see  print("Hello World! This is", anyname) 'Hello World! This is' is written within inverted commas but not 'anyname' This is because 'anyname' is a variable that contains certain value inside it but the rest of it is a string. When the program is run, the output is Hello World! This is <name entered by user>

Simple Hello World Program Tutorial

Image
Now that you know how to use IDLE, lets begin with writing our first program. The Hello World Program ( We usually do this in every language 😎) Lets begin. Fire up IDLE. Go to File>New File. Once it opens up, write the code in the new file. print("Hello World!") Now click on Save As and save the file with .py extension. See the image below. Go to Run> Run Module or Press F5 to check whether the code is working or not. It works.