Variables and Name

Now that we have created our first program and done some printing, its time to learn how to use variables and names. In any program
Now you can print things with print and you can do math. The next step is to learn about variables. In programming, a variable is nothing more than a name for something so you can use the name rather than the something as you code. Programmers use these variable

names to make their code read more like English and because they have lousy memories. If they didn’t use good names for things in their software, they’d get lost when they tried to read their code again.

Remember to write a comment above each line explaining to yourself what it does in English. Read your .py file backward.

Exercise 1




In the above example, we have defined 'applecount' as a variable and are using it for printing. we have used some string and variable together for printing. 


In ouput you see that python have put an extra space before and after applecount.

Exercise 2:

You can define a string in variables and use it as you need. To define a string in variable you need to use " ".

e.g string1 = "Apples"

Here we have used " " to define that Apples is a string. 



  1. You can write a=10 instead of a = 10, but this is not a good programming standard. 
  2. You can redefine any variable or reuse it as many time as you want.


  1. Write a code to print multiple variables in same line.
  2. Assign a variable to another variable and print it.

About the author



Please login to comment