-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment_5.py
More file actions
53 lines (43 loc) · 3.07 KB
/
Assignment_5.py
File metadata and controls
53 lines (43 loc) · 3.07 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
45
46
47
48
49
50
51
52
53
# 1.
# byte is an immutable sequence of integers(0–255) representing binary data.
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 2.
b = bytes([65, 66, 67])
print(b) # Output : b'ABC'
#The integers are converted to their ASCII character equivalents i.e.(65 → A, 66 → B, 67 → C).
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 3.
# Bytes are immutabale ,bytes are like elements in tuple they cannot be changed this is fixed binary data
# Bytearray is mutable,and modifications are allowed
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 4.
ba = bytearray([65, 66, 67])
ba[0] = 97
print(ba) #Output : bytearray(b'aBC')
# bytearray is mutable,so elements can be modified.
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 5.
# None represents the absence of a value.
# No,None is a separate data type.
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 6.
x = None
print(type(x)) #<class 'NoneType'>
print(x == False) #False
# None is not equal to False;it only evaluates to False in boolean context.
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 7.
# The Boolean data type has two values:True and False.
# false evaluating values are : false,None,0,empty list/string,any empty collection
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 8.
# A set is an unordered collection of unique elements.
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 9.
s = {10, 20, 30, 10, 20}
print(s) #{10, 20, 30}
#Some values are missing coz sets don't allow duplicates
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 10.
# Dynamic typing means variable types are decided at runtime and a variable can change its data type during execution.
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------