
Understanding Python Data Types: Numbers, Strings, and More
Discover the core data types offered by Python, including Numbers, Strings, and Complex Numbers. Learn about how to store numeric values, manipulate integers, work with floating-point numbers, and handle strings in Python programming. Explore the advantages and disadvantages of various data types such as floating-point numbers and complex numbers.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Computer Science 1/10 5/26/2020
Data types Character Integer String Python offers the following built-in core data types: 1.Numbers 2.String 5.Dictionary 3.List 4.Tuples 2
Numbers The Number data types are used to store numeric values in python. The numbers in python have following core data types: (i) Integers -> Integers(signed) Booleans (ii) Floating-point Numbers (iii)Complex Numbers 3/10 TOPIC/COURSE CODE-NAME/FACULTY/DEPT/COLLEGE 5/26/2020
Integers(signed) -> normal integer representation of whole numbers. Booleans ->These represent the truth values False and True or 0 and 1 For eg: bool(0) False bool(1) True 4
For eg: str(False) False str(True) True 5
Floating Point Numbers Fractional form(Normal Decimal Notation) eg:3500.75 Exponent Notation eg:3.50075E03,0.5E-04 Advantages: They can represent values between the integers They can represent a much greater range of values. Disadvantage: Floating-point operations are usually slower than integer operations. 6
Complex Numbers A complex number is made up of both real and imaginary components .In complex number A+Bi, A and B are real numbers and i is imaginary. 7
Strings Strings in python are surrounded by either single quotation marks, or double quotation marks. 'hello' is the same as "hello". You can display a string literal with the print() function: For eg: a = "Hello" print(a) 8
Multiline Strings a = """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.""" print(a) 9
Like many other popular programming languages, strings in Python are arrays of bytes representing unicode characters. However, Python does not have a character data type, a single character is simply a string with a length of 1. Square brackets can be used to access elements of the string. For eg: a = "Hello, World!" print(a[1]) 10
a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and the length changed, or it may be fixed. 11
List 13
Set items are unordered, unchangeable, and do not allow duplicate values. Unordered Unordered means that the items in a set do not have a defined order. Set items can appear in a different order every time you use them, and cannot be referred to by index or key. Unchangeable Set items are unchangeable, meaning that we cannot change the items after the set has been created. 18