-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatatypes.py
More file actions
45 lines (31 loc) · 1.7 KB
/
datatypes.py
File metadata and controls
45 lines (31 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#Numbers: Python has three types of numbers: integer, float, and complex. An integer is a whole number,
# a float is a number with a decimal point, and a complex number is a number with a real and imaginary part.
#Strings: A string is a sequence of characters, such as a word or a sentence. You can create a string by
# enclosing a series of characters in single or double quotes.
#Lists: A list is an ordered collection of values that can be of any data type. You can create a list by
# enclosing a series of values in square brackets and separating them with commas.
#Tuples: A tuple is similar to a list, but it is immutable, which means that you cannot
# modify the values in a tuple once it has been created. You can create a tuple by enclosing a
# series of values in parentheses and separating them with commas.
#Dictionaries: A dictionary is a collection of key-value pairs. You can create a dictionary by enclosing
# a series of key-value pairs in curly braces and separating them with commas.
#Sets: A set is an unordered collection of unique values. You can create a set by enclosing a
# series of values in curly braces and separating them with commas.
#Booleans: A Boolean value is either True or False.
# Data Type Try it
x = "Hello World" #string
x = 20 #int
x = 20.5 #float
x = ["apple", "banana", "cherry"] #list
x = ("apple", "banana", "cherry") #tuple
x = range(6) #range
x = {"name" : "John", "age" : 36} #dict
x = {"apple", "banana", "cherry"} #set
x = frozenset({"apple", "banana", "cherry"}) #frozenset
x = True #bool
x = b"Hello" #bytes
x = bytearray(5) #bytearray
x = memoryview(bytes(5)) #memoryview
x = None #NoneType
# https://youtube.com/@codewithmuh
# https://github.com/rashiddaha