Jul 1, 2018

Learning variables in Python

#!/usr/local/bin/python2.7

'''
    #Learning variables in Python
    File name: python_variables.py
    Author: Prabhath Kota
    Date: June 29, 2018
    Python Version: 2.7
'''

'''
Unlike other programming languages, Python there is no need to declare a variable.
A variable is created when you first assign a value to it.
A variable can have a short or uder understandbale name

Rules for Python variables:
A variable name cannot start with a number
Variable names are case-sensitive (height, Height and HEIGHT are three different)
A variable name must start with a letter or the underscore character
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
'''

var_a = 100
print var_a
#100

var_a = 'Hi'
print var_a
#Hi

#1_var = 'Hi'
#wrong declaration

#Case-Sensitive
height = 5.0
print height

Height = 5.2
print Height

HEIGHT = 5.6
print HEIGHT

No comments:

Post a Comment