In this tutorial you will learn:
The first thing that one needs to understand in order to learn any programming language is the answer to the question what is a variable?
Variables are the containers where you store your values. They are essentially places in memory for storing data. These containers have different types for storing different types of data. Commonly used data types and their short hand syntax are:
Integer - Int - For storing numbers such as 1,2,3,4 ….
Float - Float - For storing numbers with a floating points e.g 1.91, 2.32, 5.68 etc
Character - Char - For storing characters e.g ‘a’, ‘b’, ‘c’ etc
String - String - For storing large strings e.g “This is my first python program”
In Python you don’t declare a type ( int, float, string etc ) explicitly. Assigning a value automatically declares a variable for you and the data type is handled by python implicitly.
- myVariable = 1
- myVariable2 = 2
- myCharacter = ‘a’
- myString = “I am a programmer”
It doesn’t mean there are no data types in python it’s just that it handled by python implicitly
print(type(myVariable); #would print int
you can explicitly type cast using
myVariable = int(1)
Important variable naming rules:
2. Write a comment
Comments aren’t part of the code that will later compile but they just explain your code to other developers. They won’t effect the running of your code in any way, writing them in the code will only make it more clear. That’s how you write a comment
# This is a comment
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.