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?
Easy to learn and use
English like commands
No need to write everything from scratch.
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.
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.
Arithmetic Operation
1.Addition (+)
4.Division (/) (output of a division will always be a float)
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:
- Add and assign (+=)
- Subtract and assign (-=)
- Multiply and assign (*=)
- Divide and assign (/=)
- Modulus and assign (%=)
- Exponent and assign (**=)
- Floor Division and assign (//=)
input () function
If we want to take input from user, we usually use input () function.
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.
Top comments (0)