Wednesday, March 20, 2019

Python - VARIABLES AND DATA TYPES

1. What is a variable ?
- Variables are reserved memory locations that are used to store values and are referenced by a name.
Example: Assigning a contact number and referencing it by a contact name

2. How to define a variable?
- Syntax to define a variable is as follows:
 variableName = value
 Example: phoneNumber = 12345

3. What are the rules for declaring a variable?
- Variable name should start with an alphabet or underscore (‘_’) followed by any number of alphabets, digits and underscores
- Variable names are case sensitive.
Example: phoneNumber is different from PhoneNumber and phonenumber
- Variable name cannot be a reserved name
Example: print, if, for, etc
- Variable name cannot contain any special character other than underscore

4. What are the different data types in Python ?
In Python, data types are broadly classified into the
following:

  • Numbers
  • List
  • Tuple
  • Strings
  • Dictionary
Share:

0 comments:

Post a Comment