# Python Basics: Variables

#### Before we start with the actual topics lets have a general overview of Python

Python is a high-level and general-purpose programming language. Created by Guido van Rossum and first released in 1991. It is object-oriented and is dynamically typed. Python is meant to be an easily readable language and it often uses English keywords.


- Don't worry about all the technical terms as we dive deep into the language you will learn all the things.

- For the time being, you just have to know that:
          1. Python is a programming language, not a snake 🐍.
          2. It is the easiest language which anyone can learn in no time.
          3. And we will be using Python3 over Python2.

#### So let's program.
So let's type our first line of code. This is the code that every person in the world types when they start to learn to program.

```python
   print("Hello, World!")
   print("Hope you are doing great!!!")
```
Here ***print*** is a function that is builtin, which takes anything written in the ***parenthesis*** and the ***quotes('' ")*** and prints it out on the screen. 

## Variables
Variables are the names you give to computer memory locations that are used to store values in a computer program **OR** Variables are containers for storing values. A variable is created the moment you first assign a value to it.
```python
   Name= 'John'
   Age= 19
   Company= 'DreamLand'
   print(Name,Age,Company)
```
`Output:`
```python
   John 19 DreamLand
```
As we can see in the above example **Name**, **Age**, and **Company** are three different variables all having different values. And when the variable names are called in the **print** function they are printed on the screen.

A variable can store only one value, as we continue through the program from top to bottom, i**f the same variable name is assigned with a different value the new value takes over the previous one**, Variables do not need to be declared with any particular type and can even change type after they have been set
```python
  x=19
  x='DreamLand'
  print(x)
```
`Output:`
```python
   DreamLand
```
```python
  x=19
  x=23
  print(x)
```
`Output:`
```python
   23
```
> Unlike, other programming languages, Python has no command for declaring a variable.

### Naming of Variables

As we now know what are variables and how are they used now let's see some very important rules to create a valid Variable Name.
> Rules for Naming of Variables are the same in almost all programming languages.

**Rules:**

- 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 _ )

- A variable name cannot start with a number

- Variable names are case-sensitive (age, Age, and AGE are three different variables)

- There should be no spaces in the words


```python
  #Valid Variable names
   myvariable1="DreamLand"
   my_variable="JaneDoe"
   _variable=17
   
  #Invalid Variable names
   invalid-variable='Mahendra'
   8variable=19
   invalid name='Doe'
``` 

> When you run the above lines of code when the Python Interpreter reaches Invalid Variable names it raises a Syntax Error. Don't worry check your code correct it and carry on.

### Shorthand for assigning multiple variables in one line


```python
  fruit,color,cost= "Apple","Green",15.75
  print(fruit)
  print(color)
  print(cost)
``` 
`Output:`

```python
Apple Green 15.75
``` 


- **So this here finishes the basics of Variables hope you enjoyed the topic.**

- **Thanks for taking out your time and reading. 😄**















