-
Notifications
You must be signed in to change notification settings - Fork 0
/
otherDatatype.py
38 lines (38 loc) · 901 Bytes
/
otherDatatype.py
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
# range
rangeOfValues = range(10)
print(rangeOfValues, type(rangeOfValues))
# range print in for loop
for value in range(10):
print(value, end=" ")
rangeValue = range(5, 20)
print()
for value in rangeValue:
print(value, end=" ")
print()
valuesOfRange = range(20, 5, -2) # starting, ending, step
for value in valuesOfRange:
print(value, end=" ")
print()
ranges = range(5, 50, 2)
print(ranges[0])
print(ranges[2:5])
print(ranges[-1])
# Bytes
priceList = [10, 20, 30, 25]
newPriceList = bytes(priceList)
for value in newPriceList:
print(value, end=" ")
print(type(newPriceList))
# newPriceList[0] = 100
# print(newPriceList[0])
print()
# Bytearray
priceList = [10, 20, 30, 25]
newPriceList = bytearray(priceList)
print(priceList[0], type(newPriceList))
priceList[0]=100 # Mutable
print(priceList[0])
for value in newPriceList:
print(value, end=" ")
print(type(newPriceList))
print()