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 3d30158

Browse files
Update example syntax to python 3
1 parent 8cf51ec commit 3d30158

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

‎workshop/Introduction.md‎

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def fib(n):
239239
a, b = 0, 1
240240

241241
while a < n:
242-
print a
242+
print(a)
243243
a, b = b, a+b
244244

245245

@@ -256,7 +256,7 @@ fib(1000)
256256

257257
```python
258258
# This prints Hello World!
259-
print"Hello World!"
259+
print("Hello World!")
260260

261261
# This is a comment; single line comment
262262

@@ -265,7 +265,7 @@ And this is a multiline comment.
265265
As this could take more than one line of comments.
266266
Like this.
267267
"""
268-
print"Hello Again."
268+
print("Hello Again.")
269269
```
270270

271271
<small>Output: </small>
@@ -281,12 +281,12 @@ Hello Again.
281281

282282
```python
283283
# Printing more texts
284-
print"Hello World!"
285-
print"Hello Again."
286-
print"We enjoy typing."
287-
print"Learning python is easy."
288-
print"And fun."
289-
print"Printing text is way easier."
284+
print("Hello World!")
285+
print("Hello Again.")
286+
print("We enjoy typing.")
287+
print("Learning python is easy.")
288+
print("And fun.")
289+
print("Printing text is way easier.")
290290
```
291291

292292
<small>Output: </small>
@@ -305,12 +305,12 @@ Printing text is way easier.
305305
#### Example 3: Printing more than just texts
306306

307307
```python
308-
print"One + One =", 1 + 1
309-
print"One - Two =", 1 - 2
310-
print"Two * Five =", 1 * 5
311-
print"Four / Two =", 4 / 2
312-
print"Expression (12 * 5) - (2 ^ 3) + (1 / 2) =", ((12 * 5) - (2 ** 3) + (1 / 2))
313-
print"Seven is less than or equal to Six is", 7 <= 6
308+
print("One + One =", 1 + 1)
309+
print("One - Two =", 1 - 2)
310+
print("Two * Five =", 1 * 5)
311+
print("Four / Two =", 4 / 2)
312+
print("Expression (12 * 5) - (2 ^ 3) + (1 / 2) =", ((12 * 5) - (2 ** 3) + (1 / 2)))
313+
print("Seven is less than or equal to Six is", 7 <= 6)
314314
```
315315

316316
<small>Output: </small>
@@ -334,9 +334,9 @@ last_name = "Baidhya"
334334
dob = "July 30, 1992"
335335
home_town = "Kathmandu, Nepal"
336336

337-
print"Hi! I am", first_name, last_name, "."
338-
print"I was born on", dob, "."
339-
print"I'm from", home_town, "."
337+
print("Hi! I am", first_name, last_name, ".")
338+
print("I was born on", dob, ".")
339+
print("I'm from", home_town, ".")
340340
```
341341

342342
<small>Output: </small>
@@ -359,9 +359,9 @@ dob_day = 30
359359
dob_year = 1992
360360
difficulty = "easy"
361361

362-
print"Hi! I am %s %s." % (first_name, last_name)
363-
print"I was born on %s %d, %d." % (dob_month, dob_day, dob_year)
364-
print"Python is %s to learn." % difficulty
362+
print("Hi! I am %s %s." % (first_name, last_name))
363+
print("I was born on %s %d, %d." % (dob_month, dob_day, dob_year))
364+
print("Python is %s to learn." % difficulty)
365365
```
366366

367367
<small>Output: </small>
@@ -377,14 +377,14 @@ Python is easy to learn.
377377
#### Example 6: User Input
378378

379379
```python
380-
print"What is your name?",
380+
print("What is your name?")
381381

382382
# This would take input from the user
383383
# and store it in a variable.
384384
name = raw_input()
385385

386-
print"Hi! %s. \nIt's nice to meet you." % (name)
387-
print"Hope you're doing good."
386+
print("Hi! %s. \nIt's nice to meet you." % (name))
387+
print("Hope you're doing good.")
388388
```
389389

390390
<small>Output: </small>
@@ -431,10 +431,10 @@ a_floating_point = 17.60
431431
a_boolean = True
432432
a_string = "Foo"
433433

434-
print"Integer value = %d" % an_integer
435-
print"Float value = %f" % a_floating_point
436-
print"Boolean value = %r" % a_boolean
437-
print"String value = %s" % a_string
434+
print("Integer value = %d" % an_integer)
435+
print("Float value = %f" % a_floating_point)
436+
print("Boolean value = %r" % a_boolean)
437+
print("String value = %s" % a_string)
438438
```
439439

440440
<small>Output: </small>
@@ -457,9 +457,9 @@ numbers = [1, 2, 3, 4, 5, 6, 7, 8]
457457
# This is called list comprehension
458458
even_numbers = [x for x in numbers if x % 2 == 0]
459459

460-
print"Numbers: %s" % numbers
461-
print"Even Numbers: %s" % even_numbers
462-
print"Fruits: %s, %s and %s" % (fruits[0], fruits[1], fruits[2])
460+
print("Numbers: %s" % numbers)
461+
print("Even Numbers: %s" % even_numbers)
462+
print("Fruits: %s, %s and %s" % (fruits[0], fruits[1], fruits[2]))
463463
```
464464

465465
<small>Output: </small>
@@ -481,9 +481,9 @@ data = {
481481
"home_town": "Kathmandu, Nepal"
482482
}
483483

484-
print"Hi! I am %s." % data["name"]
485-
print"I was born on %s." % data["dob"]
486-
print"I'm from %s." % data["home_town"]
484+
print("Hi! I am %s." % data["name"])
485+
print("I was born on %s." % data["dob"])
486+
print("I'm from %s." % data["home_town"])
487487
```
488488

489489
<small>Output: </small>

0 commit comments

Comments
(0)

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