![]() ![]() Tuples are ordered collections of elements that are unchangeable. Įxample list creation and manipulation my_list = By enclosing elements in the square brackets.The list is mutable which means we can modify the value of list elements.Duplicates elements are allowed in the list.The list can contain data of all data types such as int, float, string.For example: If we want to store all student’s names, we can use list type. We use the list data type to represent groups of the element as a single entity. List elements can be accessed, iterated, and removed according to the order they inserted at the creation time. The Python List is an ordered collection (also known as a sequence ) of elements. If we are trying to represent an imaginary part as binary, hex, or octal, we will get an error. But the imaginary part should be represented using the decimal form only. The integer value can be in the form of either decimal, float, binary, or hexadecimal. The real part of the complex number is represented using an integer value. ![]() Z = 11.2 + 1.2j # both value are float type Example x = 9 + 8j # both value are int type If we want to declare a complex value, then we can use the a+bj form. The complex type is generally used in scientific applications and electrical engineering applications. Print(type(num1)) # class 'float' Complex data typeĪ complex number is a number with a real and an imaginary component represented as a+bj where a and b contain integers or floating-point values. The benefit of using the exponential form to represent floating-point values is we can represent large values using less memory. # store a floating-point value using float() classįloating-point values can be represented using the exponential form, also called scientific notation. Directly assigning a float value to a variable.We can create a float variable using the two ways The float type in Python is represented using a float class. For example, if we want to store the salary, we can use the float type. To represent floating-point values or decimal values, we can use the float data type. Print(type(binary_num)) # class 'int' Float data type Print(type(hexadecimal_num)) # class 'int'īinary_num = 0b10000 # decimal equivalent of 6 Hexadecimal_num = 0x10 # decimal equivalent of 21 ![]() You can also store integer values other than base 10 such as
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |