2
2
3
3
## String
4
4
* String is a sequence of characters.
5
- * We have seen the string representation in previous chaptor .
5
+ * We have seen the string representation in previous chapter .
6
6
* Python provides lots of built in method associated with it.
7
7
8
8
### Side by side string literals
73
73
>>>
74
74
```
75
75
76
- ### Strip some characters from a strin
76
+ ### Strip some characters from a string
77
77
```
78
78
>>> a = "abc\n"
79
79
>>> a.strip() # It will remove new line
98
98
20
99
99
```
100
100
### String Indexing
101
- * First character of a string has index 0 .
102
- * Negative indices start form -1 , when counted from right.
101
+ * First character of a string has index ` 0 ` .
102
+ * Negative indices start form ` -1 ` , when counted from right.
103
103
```
104
104
>>> word = "Welcome to FOSS MEET"
105
105
>>> word[0]
113
113
```
114
114
115
115
### String Slicing
116
- * string[ x: y ] -> returns the string starting from index x to y-1.
116
+ * ` string[x:y] ` returns the string starting from index ` x ` to ` y-1 ` .
117
117
```
118
118
>>> word[2:8]
119
119
'lcome '
@@ -132,7 +132,7 @@ TypeError: 'str' object does not support item assignment
132
132
133
133
## List
134
134
* Comma separated values between square brackets
135
- * List can be sliced, indexed and cancatenated
135
+ * List can be sliced, indexed and concatenated
136
136
* Lists are mutable it means we can append and remove items from a list.
137
137
```
138
138
>>> a = [1,2,3,4,5,6]
@@ -193,8 +193,8 @@ which follow it.
193
193
```
194
194
195
195
## Tuples
196
- * Items seperated by comma in a closed bracket.
197
- * These are immutables it means we cannot append or remove date from it.
196
+ * Items separated by comma in a closed bracket.
197
+ * These are immutable, it means we cannot append or remove data from it.
198
198
```
199
199
>>> a = (1,2,3,'hello')
200
200
>>> a
@@ -227,14 +227,14 @@ TypeError: 'tuple' object doesn't support item deletion
227
227
```
228
228
229
229
## Set
230
- A list of items with no duplicates in curlie braces.
230
+ A list of items with no duplicates in curly braces.
231
231
```
232
232
>>> a = 'axbecjnn2226'
233
233
>>> set(a)
234
234
{'n', 'e', 'a', '6', 'x', 'b', 'j', '2', 'c'}
235
235
>>>
236
236
```
237
- * Define another set b and try out a -b , a | b, a & b, a ^ b
237
+ * Define another set ` b ` and try out ` a - b ` , ` a | b ` , ` a & b ` , ` a ^ b `
238
238
* We can also add and remove values from set
239
239
```
240
240
>>> c
@@ -247,12 +247,11 @@ A list of items with no duplicates in curlie braces.
247
247
```
248
248
249
249
## Dictionaries
250
- * Unordered set of key: value pairs under {} braces where keys are unique
250
+ * Unordered set of key: value pairs under ` {} ` braces.
251
251
* Keys are unique in nature.
252
- * Dictionaries are mutable buts keys are immutable
253
- * By using particular Keys, we can updat the value.
254
- * Values can be numbers, string, list, or tuples.
255
- * We can access valuing dictionary.
252
+ * Dictionaries are mutable but keys must be of immutable type.
253
+ * By using particular key, we can access or update the value.
254
+ * Values can be of any data type.
256
255
```
257
256
>>> mydict = {'number': 1, 'letter': 'foobar', 'mytuple':(1,2,3), 'foobar': [1,2,3,4]}
258
257
>>> mydict
@@ -278,10 +277,10 @@ True
278
277
>>> len(mydict)
279
278
4
280
279
```
281
- We can always run a loop over list, string, tuples and dict:
280
+ We can always run a loop over list, string, tuple and dict:
282
281
283
282
### Fun time
284
- * Create a dictionary which has keys like numbers, strings, tuples, list, set and dict and put some value.
283
+ * Create a dictionary which has keys like numbers, strings, tuples, list, set and dict and put some value.
285
284
Run a for loop and print their data types and their content.
286
285
287
286
* Checkout lambda and map function
0 commit comments