You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,13 @@ What do I mean by dynamic? Well, with a dynamically typed language you can do th
9
9
```sh
10
10
>>> variable = 1
11
11
>>> type(variable)
12
-
<type'int'>
12
+
<class'int'>
13
13
>>> variable = "Foo"
14
14
>>> type(variable)
15
-
<type'str'>
15
+
<class'str'>
16
16
>>> variable = ["bar",10]
17
17
>>> type(variable)
18
-
<type'list'>
18
+
<class'list'>
19
19
```
20
20
21
21
Essentially, you can change the datatype (from an integer to a string to a list, in the above example) at any point in a program. In a statically typed language, this would result in an error when compiled.
@@ -191,7 +191,7 @@ Ruby has a bigger web presence with Rails than Python does with Django, so if yo
191
191
That said, take a look at the two code snippets below -
192
192
193
193
```python
194
-
print"Hello, World!"
194
+
print("Hello, World!")
195
195
```
196
196
197
197
and
@@ -242,34 +242,34 @@ Guessing game ...
242
242
243
243
```python
244
244
import random
245
-
import os
245
+
246
246
247
247
number = random.randint(1, 20)
248
248
guesses =0
249
249
250
-
print'Hello! What is your name?'
251
-
name =raw_input()
250
+
print('Hello! What is your name?')
251
+
name =input()
252
252
253
-
print"Hi, {}. I'm thinking of a number from 1 and 20.".format(name)
253
+
print("Hi, {}. I'm thinking of a number from 1 and 20.".format(name))
254
254
255
255
while guesses <6:
256
256
257
-
print'What is your guess. You have {} more guesses.'.format(6-guesses)
258
-
guess =raw_input()
257
+
print('What is your guess. You have {} more guesses.'.format(6-guesses))
258
+
guess =input()
259
259
guess =int(guess)
260
260
261
261
guesses = guesses +1
262
262
263
263
if guess < number:
264
-
print'Too low.'
264
+
print('Too low.')
265
265
elif guess > number:
266
-
print'Too high.'
266
+
print('Too high.')
267
267
elif guess == number:
268
-
print'Good job, {}! You guessed my number in {} guesses!'.format(name,guesses)
268
+
print('Good job, {}! You guessed my number in {} guesses!'.format(name,guesses))
269
269
break
270
270
271
271
if guess != number:
272
-
print'Nope. The number I was thinking of was {}.'.format(number)
272
+
print('Nope. The number I was thinking of was {}.'.format(number))
0 commit comments