5 967
Subscribers
No data24 hours
-357 days
-22530 days
Posts Archive
5 967
ARITHMETIC OPERATOR : Arithmetic operators are used with numeric values to perform common mathematical operations: There are following operators in arithmetic Operator
5 967
WHAT IS OPERATORS ?
Operators are special symbols in Python that carry out arithmetic or logical computation. The value that the operator operates on is called the operand.
5 967
EXPLICIT TYPE CONVERSION
In Explicit Type Conversion, users convert the data type of an object to required data type. We use the predefined functions like int(), float(), str(), etc to perform explicit type conversion.
This type of conversion is also called typecasting because the user casts (changes) the data type of the objects.
5 967
IMPLICIT TYPE CONVERSION
In Implicit type conversion, Python automatically converts one data type to another data type. This process doesn't need any user involvement.
Let's see an example where Python promotes the conversion of the lower data type (integer) to the higher data type (float) to avoid data loss.
5 967
TYPE CONVERSION IN PYTHON
The process of converting the value of one data type (integer, string, float, etc.) to another data type is called type conversion. Python has two types of type conversion.
1.) Implicit Type Conversion
2.) Explicit Type Conversion
5 967
WHAT IS DATA TYPE ?
Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes.
STANDARD DATA TYPE OF PYTHON
Numeric
Sequence Type
Boolean
Set
Dictionary
5 967
MULTI WORDS VARIABLE NAMES
Variable names with more than one word can be difficult to read.
There are several techniques you can use to make them more readable:
CAMEL CASE Each word, except the first, starts with a capital letter:
myVariableName = "John"
PASCAL CASE Each word starts with a capital letter: MyVariableName = "John"
SNAKE CASE Each word is separated by an underscore character: my_variable_name = "John"
KEBAB CASE Kebab case combines words by replacing each space with a dash (-), as follows: user-login-count = "John"5 967
RULES FOR DECLARING VARIABLE ?
A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for Python variables are :
• A variable name must start with a letter or the underscore character
• A variable name cannot start with a number
• A variable name should not have space between them
• A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
• Variable names are case-sensitive (age, Age and AGE are three different variables)
5 967
CREATING VARIABLES :
Python has no command for declaring a variable.
A variable is created the moment you first assign a value to it.
5 967
WHAT IS VARIABLES ?
Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.
Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can store integers, decimals or characters in these variables.
