|
9 | 9 | ############### |
10 | 10 |
|
11 | 11 | var = 13.2 |
12 | | -print(var) |
| 12 | +print(type(var)) |
13 | 13 | #13.2 |
14 | 14 |
|
15 | 15 | type (var) |
16 | 16 | #<class ‘float’> |
17 | 17 |
|
18 | 18 | var = "Now the type is string" |
19 | | -print(var) |
| 19 | +print(type(var)) |
20 | 20 |
|
21 | 21 | type(var) |
22 | 22 | #<class ‘str’> |
|
36 | 36 | ''' |
37 | 37 |
|
38 | 38 | bool(False) |
| 39 | +print(bool(False)) |
39 | 40 | #False |
40 | 41 | va1 = 0 |
41 | 42 | print(bool(va1)) |
|
50 | 51 | #True |
51 | 52 |
|
52 | 53 | #### Strings |
53 | | -Str1 = 'Hello how are you' |
| 54 | +str1 = 'Hello how are you' |
54 | 55 | str2 = "Hello how are you" |
55 | 56 | str3 = 'multiline'+'string'; |
| 57 | +print(str1) |
| 58 | +print(str2) |
56 | 59 | print(str3) |
57 | 60 |
|
58 | 61 | f = 'data' |
|
69 | 72 | print(3 * st) |
70 | 73 | #'data.data.data.' |
71 | 74 |
|
| 75 | +###### Range ###### |
| 76 | + |
| 77 | +print(list(range(10))) |
| 78 | +print(range(10)) |
| 79 | +print(list(range(10))) |
| 80 | +print(range(1,10,2)) |
| 81 | +print(list(range(1,10,2))) |
| 82 | +print(list(range(20,10,-2))) |
| 83 | + |
| 84 | +#[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
| 85 | +#range(0, 10) |
| 86 | +#[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
| 87 | +#range(1, 10, 2) |
| 88 | +#[1, 3, 5, 7, 9] |
| 89 | +#[20, 18, 16, 14, 12] |
| 90 | + |
72 | 91 |
|
73 | 92 | ###### Lists ###### |
74 | 93 |
|
|
209 | 228 | if thirdList is Secondlist: |
210 | 229 | print("Both are pointing to the same object") |
211 | 230 | else: |
212 | | - print("Both are not pointing to the same object ") |
| 231 | + print("Both are not pointing to the same object") |
213 | 232 | ''' |
214 | 233 | Output: |
215 | 234 | Both are equal |
|
223 | 242 | Firstlist = [] |
224 | 243 | Secondlist = [] |
225 | 244 | if Firstlist is not Secondlist: |
226 | | - print("Both are pointing to the different object") |
| 245 | + print("Both Firstlist and Secondlist variables are the same object") |
227 | 246 | else: |
228 | | - print("Both are not pointing to the different object ") |
| 247 | + print("Both Firstlist and Secondlist variables are not the same object") |
229 | 248 |
|
230 | 249 | #Output: |
231 | | -# Both are pointing to the different object |
| 250 | +# Both Firstlist and Secondlist variables are the same object |
232 | 251 |
|
233 | 252 |
|
234 | 253 |
|
|
461 | 480 |
|
462 | 481 | from collections import deque |
463 | 482 | s = deque() # Creates an empty deque |
| 483 | +print(s) |
464 | 484 | my_queue = deque([1, 2, 'Name']) |
465 | 485 | print(my_queue) |
466 | 486 | #deque([1, 2, 'Name']) |
|
506 | 526 |
|
507 | 527 | print(chain) |
508 | 528 | #ChainMap({'data': 1, 'structure': 2}, {'python': 3, 'language': 4}) |
509 | | -print (list(chain.keys())) |
| 529 | +print(list(chain.keys())) |
510 | 530 | #['python', 'language', 'data', 'structure'] |
511 | | -print (list(chain.values())) |
| 531 | +print(list(chain.values())) |
512 | 532 | #[3, 4, 1, 2] |
513 | 533 | print(chain["data"]) |
514 | 534 | #1 |
|
0 commit comments