Icon
Login    Register          




Most Advanced AI

Generate Code at the speed of Thought

Improve Productivity of Developers



Python Tutorial

Python Data Types

Python data types are the different types of data that can be stored and manipulated in a Python program. Python has several built-in data types, including numbers, strings, lists, tuples, dictionaries, and sets.

1. Numbers: Numbers are used to store numerical values. They can be integers (whole numbers), floats (decimal numbers), or complex numbers. Examples of numbers include:

- Integer: 5, -10, 0
- Float: 3.14, -2.5, 0.0
- Complex: 3+4j, -2+5j

2. Strings: Strings are used to store text values. They are enclosed in single or double quotes. Examples of strings include:

- 'Hello World!'
- "Python is awesome!"
- '12345'

3. Lists: Lists are used to store a collection of values. They are enclosed in square brackets and the values are separated by commas. Examples of lists include:

- [1, 2, 3, 4]
- ['apple', 'banana', 'cherry']
- [1.2, 3.4, 5.6]

4. Tuples: Tuples are used to store a collection of values. They are enclosed in parentheses and the values are separated by commas. Examples of tuples include:

- (1, 2, 3, 4)
- ('apple', 'banana', 'cherry')
- (1.2, 3.4, 5.6)

5. Dictionaries: Dictionaries are used to store key-value pairs. They are enclosed in curly brackets and the key-value pairs are separated by commas. Examples of dictionaries include:

- {'name': 'John', 'age': 20}
- {'fruit': 'apple', 'vegetable': 'carrot'}
- {1: 'one', 2: 'two'}

6. Sets: Sets are used to store a collection of unique values. They are enclosed in curly brackets and the values are separated by commas. Examples of sets include:

- {1, 2, 3, 4}
- {'apple', 'banana', 'cherry'}
- {1.2, 3.4, 5.6}


Search Menu



Disclaimer:
Patodia Infotech Private Limited (fastdevai.com) has no responsibility for any text or code generated or for any action taken by you based on the contents provided by this web site. The use of this web site is solely at the user's risk. All the services are provided with the understanding that Patodia Infotech Private Limited or any other person or company associated with this company or website are not responsible for any loss or damage occurring to anybody from any code or contents generated by this website. Please note that text, codes and contents are generated by AI. These are state-of-the-art AI solutions. However, these are AI tools so there is no guarantee of accuracy of any code or contents generated.


Copyright © 2021-2024 Patodia Infotech Private Limited, All Rights Reserved.