WAYS TO USE SINGLE QUOTES , DOUBLE QUOTES AND TRIPLE QUOTES IN A STRING
NOTE -
Multi - line string can only be stored in triple quotes.
If you want some inverted commas to be the part of your string then you can use triple quotes.
METHOD TO IDENTIFY THE DATATYPE OF VARIABLE
- use type function
NOTE - From datatype of variable 'd' you can clearly figure out that if you store any datatype inside quotes in any variable then that datatype will be considered as string only
OPERATORS IN PYTHON
ARITHMETIC OPERATORS - These are used to perform arithmetic operations on variables ARITHMETIC OPERATORS ARE +,-,/,* etc
NOTE - From the above example we can see that whenever we perform division operation on 2 numbers in python then it returns the answer in float datatype
And dont forget to use the higlighted comma in between otherwise it will show error
ASSIGNMENT OPERATORS - These are used to assign a value to the variable ASSIGNMENT OPERATORS ARE =,+=,-=,/=,*= etc
COMPARISON OPERATOR - These are used to compare two expressions and tell whether it is true or false . COMPARISON OPERATORS ARE ==,>,>=,<,<=,!=
LOGICAL OPERATOR - Logical operators in python are used on conditional statements i.e. on true and false Logical operators are and , or , not
- and returns true if both the values are true
- or returns true if any one of the values is true
- not makes true , false and false , true
TYPE FUNCTION AND TYPECASTING
TYPE CASTING INT TO FLOAT AND STRING
TYPECASTING FLOAT TO INT AND STRING
TYPECASTING STR TO INT AND FLOAT
NOTE - If the string contains decimal point then you cannot directly typecaste it into integer datatype , you first need to convert it into float and then to integer
INPUT FUNCTION
It allows the coder to take input from the users as a string
SYNTAX: a=input('enter something')