Python Experiment No:3 Study and Implementation Data Types and Math function.
Study and Implementation Data Types and Math function.
Aim:- Find roots of given quadratic equation.
Theory:-
Integral Types
Python provides two built-in integral types, int and bool. Both integers and Booleans are immutable.
Integers
The size of an integer is limited only by the machine’s memory, so integers hundreds of digits long can easily be created and worked with—although they will be slower to use than integers that can be represented natively by the machine’s processor.
Booleans
There are two built-in Boolean objects: True and False. Like all other Python data types (whether built-in, library, or custom), the bool data type can be called as a function—with no arguments it returns False, with a bool argument it returns a copy of the argument, and with any other argument it attempts to convert the given object to a bool.
Floating-Point Types
Python provides three kinds of floating-point values: the built-in float and complex types, and the decimal. Decimal type from the standard library. All three are immutable.
Floating-Point Numbers
The float data type can be called as a function—with no arguments it returns 0.0, with a float argument it returns a copy of the argument, and with any other argument it attempts to convert the given object to a float.
Complex Numbers
The complex data type is an immutable type that holds a pair of floats, one representing the real part and the other the imaginary part of a complex number. Literal complex numbers are written with the real and imaginary parts joined by a + or - sign, and with the imaginary part followed by a j.
Decimal Numbers
Aim:- Find roots of given quadratic equation.
Theory:-
Integral Types
Python provides two built-in integral types, int and bool. Both integers and Booleans are immutable.
Integers
The size of an integer is limited only by the machine’s memory, so integers hundreds of digits long can easily be created and worked with—although they will be slower to use than integers that can be represented natively by the machine’s processor.
Booleans
There are two built-in Boolean objects: True and False. Like all other Python data types (whether built-in, library, or custom), the bool data type can be called as a function—with no arguments it returns False, with a bool argument it returns a copy of the argument, and with any other argument it attempts to convert the given object to a bool.
Floating-Point Types
Python provides three kinds of floating-point values: the built-in float and complex types, and the decimal. Decimal type from the standard library. All three are immutable.
Floating-Point Numbers
The float data type can be called as a function—with no arguments it returns 0.0, with a float argument it returns a copy of the argument, and with any other argument it attempts to convert the given object to a float.
Complex Numbers
The complex data type is an immutable type that holds a pair of floats, one representing the real part and the other the imaginary part of a complex number. Literal complex numbers are written with the real and imaginary parts joined by a + or - sign, and with the imaginary part followed by a j.
Decimal Numbers
In many applications the numerical inaccuracies that can occur when using floats don’t matter,and in any case are far outweighed by the speed of calculation that floats offer. But in some caseswe prefer the opposite trade-off, and want complete accuracy,even at the cost of speed.
Strings
Strings are represented by the immutable str data type which holds a sequence of Unicode characters. The str data type can be called as a function to create string objects—with no arguments it returns an empty string, with a nonstring argument it returns the string form of the argument, and with a string argument it returns a copy of the string. The str() function can also be used as a conversion function, in which case the first argument should be a string or something convertable to a string, with up to two optional string arguments being passed, one specifying the encoding to use and the other specifying how to handle encoding errors.
Strings
Strings are represented by the immutable str data type which holds a sequence of Unicode characters. The str data type can be called as a function to create string objects—with no arguments it returns an empty string, with a nonstring argument it returns the string form of the argument, and with a string argument it returns a copy of the string. The str() function can also be used as a conversion function, in which case the first argument should be a string or something convertable to a string, with up to two optional string arguments being passed, one specifying the encoding to use and the other specifying how to handle encoding errors.
Maths Function’s
Q1) Explain the procedure to use math function in python program.
Q2) Explain format method with string data type.
Comments
Post a Comment