Introduction DataTypes:
Well Python supports multiple data types:
- int: Integer numbers (e.g., 10)
- float: Decimal numbers (e.g., 3.14)
- str: String (e.g., "Hello")
- bool: Boolean (e.g., True, False)
- list: Ordered collection (e.g., [1, 2, 3])
- tuple: Immutable ordered collection (e.g., (1, 2, 3))
- dict: Key-value pairs (e.g., {"name": "Shailesh", "age": 25})
- set: Unordered collection of unique items (e.g., {1, 2, 3})
Dear Read We are discuss in Details Every Datatype examples:
- int (Integer) : Stores whole numbers(positive or negative)
age = 23
print(age) #output= 23
- float (floating Point): Stores decimal numbers.
pi = 3.14print(pi) # Output: 3.14
pi = 3.14
print(pi) # Output: 3.14
- str(String) : Stores a sequence of character.
- We are discuss about string details in next chapter.
greeting = "Hello, Shailesh!"print(greeting) # Output: Hello, Shailesh!
- bool (Boolean) :- Represents either True or False
is_logged_in = True #Boolean print(is_logged_in) # Output: True
- list : An ordered, mutable collection of elements.
fruits = ["apple", "banana", "cherry"] #list print(fruits) # Output: ['apple', 'banana', 'cherry']
- tuple: An order, immutable collection of elements
coordinates = (10, 20, 30) #tuples print(coordinates) # Output: (10, 20, 30)- dict( Dictionary) :- Stores key value pairs.
person = {"name": "Shailesh", "age": 25} #dictionary print(person) # Output: {'name': 'Shailesh', 'age': 25}
- set: An unordered collection of unique items. mathematics bala set just imagine set chapter 1 class 11th.
unique_numbers = {1, 2, 3, 2, 1} #set print(unique_numbers) # Output: {1, 2, 3}
greeting = "Hello, Shailesh!"
print(greeting) # Output: Hello, Shailesh!
- bool (Boolean) :- Represents either True or False
is_logged_in = True #Boolean
print(is_logged_in) # Output: True
- list : An ordered, mutable collection of elements.
fruits = ["apple", "banana", "cherry"] #list
print(fruits) # Output: ['apple', 'banana', 'cherry']
- tuple: An order, immutable collection of elements
coordinates = (10, 20, 30) #tuples
print(coordinates) # Output: (10, 20, 30)
- dict( Dictionary) :- Stores key value pairs.
person = {"name": "Shailesh", "age": 25} #dictionary
print(person) # Output: {'name': 'Shailesh', 'age': 25}
- set: An unordered collection of unique items. mathematics bala set just imagine set chapter 1 class 11th.
unique_numbers = {1, 2, 3, 2, 1} #set
print(unique_numbers) # Output: {1, 2, 3}
Guys Each of these data types serves different purposes and can be used based on the requirements of your program based so, hope this is helpful for you.
For Better Understanding pls following my YOUTUBE CHANEEL PLAYLIST
Comments