Python Unit - 2
Python Unit - 2
Numbers – Introduction to Numbers – Integers – Double precision This contains Whole number
floating point numbers – Complex numbers – Operators – Numeric type Example:
functions – Sequences: Strings, Lists and Tuples – Sequences – Strings a=5
and strings operators – String built-in methods – Lists – List type Built print ("The type of a", type(a))
in Methods – Tuples. Output:
The type of a <class 'int'>
DATA TYPES 2. int () Function
It converts the string into integer.
Syntax
int (value, base)
Example:
a=int(input(“Enter the Value: ”))
FLOATING POINT NUMBERS
This contains real numbers.
Example:
b = 40.5
print("The type of b", type(b))
NUMBERS Output:
Introduction to Numbers The type of b <class 'float'>
Numeric values are stored in numbers. float () Function
Python supports three kinds of numerical data. It converts the string into Floating point.
o int Syntax
o float float (value, base)
o complex Example:
a=float(input(“Enter the Value: ”))
It performs a specific operation between two operands. Value is assigned to the left operand.
3. Comparison operators
Compare the values of the two operands.
Operator Name of Operator Meaning
== Equal Check the two operands are equal
OUTPUT
!= Not Equal Check the two operands are not equal
<= Less than (or) Equal Check the operand is less than or equal
Subtraction: a - b Addition: a + b
Multiplication: a * b Subtraction: a - b
2. Exponentiation: Division: a / b
1. Basic Arithmetic Operations: Returns the maximum value among the arguments.
1. + str1 = "Hello"