Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d3e3b82

Browse files
Fixes in beginning.md
1 parent 624bbbb commit d3e3b82

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

‎beginning.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ True
177177

178178
## Logical Operator
179179
* `and` and `or` are a logical operator.
180-
* `x` and `y` returns `False` if `x` is `False` else it returns evaluation of `y`.
180+
* `x and y` returns `False` if `x` is `False` else it returns evaluation of `y`.
181181
If `x` is `True`, it returns `True`.
182182
```
183183
>>> 1 and 4
@@ -196,7 +196,8 @@ True
196196
* `x operator = expression` is the syntax for shorthand operators.
197197
```
198198
>>> a = 15
199-
>>> b += 30
199+
>>> b = 2
200+
>>> b += 30 # Same as b = b + 30
200201
>>> b
201202
32
202203
```
@@ -241,9 +242,9 @@ ValueError: invalid literal for int() with base 10: 'hello'
241242
'1.5'
242243
```
243244

244-
## String Cancatanation
245+
## String Concatenation
245246
* Same type of string literals can be joined
246-
* if the variable is not same type then convert it by using *+*
247+
* if the variable is not same type then convert it by using `+`
247248
```
248249
>>> a = 'hello'
249250
>>> b = 'COEP'
@@ -258,8 +259,8 @@ TypeError: cannot concatenate 'str' and 'int' objects
258259
'hello10'
259260
```
260261

261-
## Writting a program in file
262-
* All programs are written with `<filename>.py`.
262+
## Writing a program in file
263+
* All Python programs are written with `.py` extension.
263264
* Create a file named `first_program.py` and write the following code.
264265
```
265266
#!/usr/bin/env python3
@@ -275,7 +276,7 @@ $ chomd +x first_program.py
275276
```
276277
$./first_program.py
277278
```
278-
* On the first line you can `#!`, what we call it [sha-bang](https://en.wikipedia.org/wiki/Shebang_(Unix).
279+
* On the first line you can `#!`, what we call it [sha-bang](https://en.wikipedia.org/wiki/Shebang_\(Unix\)).
279280
The `sha-bang` indicates that the Python interpreter should run this code.
280281

281282
## Decision Making using if, else
@@ -294,7 +295,7 @@ elif expression:
294295
else:
295296
do something else
296297
```
297-
It works only when expression is true otherwise it goes to next line.
298+
It works only when expression is `True` otherwise it goes to next line.
298299
```
299300
>>> a = 100
300301
>>> if a % 2 == 0:
@@ -307,8 +308,10 @@ Even Number
307308
```
308309
### Truth value testing
309310
```
310-
if a:
311-
pass
311+
>>> a = True
312+
>>> if a:
313+
... print("a is True")
314+
a is True
312315
```
313316

314317
## Functions
@@ -321,28 +324,28 @@ def function_name(function_arguments):
321324
do some stuff
322325
return something
323326
```
324-
* Here function_arguments are not necessary.
327+
* Here function_arguments are not mandatory.
325328
* function arguments can be passed in any fashion
326-
* If return is not define, it will not return anything (None).
329+
* If return is not define, it will `None`.
327330
```
328331
>>> def sum(a, b):
329332
... print(a + b)
330333
...
331334
>>> sum(2,3)
332335
5
333-
>>> sum(a=2,b=3)
336+
>>> sum(a=2,b=3)
334337
5
335-
>>> x = sum(1, 2)
338+
>>> return_value = sum(1, 2)
336339
3
337-
>>> print(x)
340+
>>> print(return_value)
338341
None
339342
>>> def sum(a, b):
340343
... return a + b
341344
...
342-
>>> x = sum(1, 2)
343-
>>> x
345+
>>> result = sum(1, 2)
346+
>>> result
344347
3
345-
>>> print(x)
348+
>>> print(result)
346349
3
347350
```
348351

@@ -358,7 +361,7 @@ None
358361
```
359362

360363
### For loop
361-
In Python loop works over a `Iterator` object.
364+
In Python loop works over a `Iterator` object,
362365
might be a `list`, `string`, `tuples`, `dictionary`, `set` etc.
363366
```
364367
for i in sequence:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /