PYTHON FOR BEGINNERS Part 1
Tags: python, machinelearning, beginners, tutorial
Published: 2022-11-17 17:47:40


## WHAT IS PYTHON?

In today’s data age, python has become one of the major leading languages to work with. It is not only used to connect to various database systems but also for making accessing, working and modifying them easy. Python is an object-oriented, high-level programming language with integrated dynamic semantics primarily for web and app development.

## WHY PYTHON IS USEFUL?

1. Easy to learn and use

2. English like commands

3. No need to write everything from scratch.

4. Lengthy problems solved in few lines with the help of libraries

## INTRODUCTION TO PYTHON

**VARIABLE AND DATA TYPES**

VARIABLE: Variable is a reserved memory location where we can store the values.

Suppose you are John. You want to print your name as an output. So, first you have to declare a variable. Put your name on the variable then print your name.




![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3q4scxwhyro20y7qecqw.png)

Here name is a variable and "John" is the value.

DATA TYPES:

We use variables to store values and every value in python has a data type.

Integer: 4,6,8,9.
Float: 2.3,5.7,9.8.
Complex Number: 5+3i,7+2i,10+3i (Here i is imaginary number)
String: "John","Adam"
List: ['red','blue','green']
Tuple: ('red','blue','green')
Boolean: True or False
Dictionary: {"name":"John","age":"22",}



## type() function
There is a function named type which we mostly use to find a type of a variable.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z6n31det16dqnr2xibxv.png)

## Arithmetic Operation

1.Addition (+)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3zu1avo93dp5dunb1i7.png)
2.Subtraction (-)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdwz90dbg9ytdpum7558.png)
3.Multiplication (*)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0umyh2dppizlhsibvgul.png)
4.Division (/) (output of a division will always be a float)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jk895ki5jdjxlpbp3xg0.png)
5.Floor Division (//)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3pdsitoy6rgc12iysfvt.png)
6.Modulus (%)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0dbpssadqoi7hppb5wom.png)
7.Exponentation (**)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7h7lkvh0isl2fkmkhqmq.png)

## Assignment Operators
If we want to add or multiply a number from a variable(a) and store the value on the variable we added or multiplied from (a=a+7 or a=a*7), then we have to use these assignment operators:

1. Add and assign (+=)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vquxgk25bvhuehtdv6jd.png)
2. Subtract and assign (-=)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xyjdqdpg73px1vpzjji3.png)
3. Multiply and assign (*=)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7kpw9zzj501ozck4ag1.png)
4. Divide and assign (/=)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f46pf5x0nhp773c31n5x.png)
5. Modulus and assign (%=)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a1wrjbj55hm7sdtb8zek.png)
6. Exponent and assign (**=)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wh1s0ufkx6n1srpg4z87.png)

7. Floor Division and assign (//=)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4viaviy9dgxt0okjykx.png)

## input () function
If we want to take input from user, we usually use input () function.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/20iyftonuikhl1gacvuq.png)
Basically, input function always returns a string.
[]

So, if we want a numeric value as an output, we have to convert the string with int,float or any kind of built in functions.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k281cwydfv6rbe4eq4u5.png)