Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions guess.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
number = random.randint(1, 20)
guesses = 0

print 'Hello! What is your name?'
name = raw_input()
print('Hello! What is your name?')
name = input()

print "Hi, {}. I'm thinking of a number from 1 and 20.".format(name)
print("Hi, {}. I'm thinking of a number from 1 and 20.".format(name))

while guesses < 6:

print 'What is your guess. You have {} more guesses.'.format(6-guesses)
guess = raw_input()
print('What is your guess. You have {} more guesses.'.format(6-guesses))
guess = input()
guess = int(guess)

guesses = guesses + 1

if guess < number:
print 'Too low.'
print('Too low.')
elif guess > number:
print 'Too high.'
print('Too high.')
elif guess == number:
print 'Good job, {}! You guessed my number in {} guesses!'.format(name,guesses)
print('Good job, {}! You guessed my number in {} guesses!'.format(name,guesses))
break

if guess != number:
print 'Nope. The number I was thinking of was {}.'.format(number)
print('Nope. The number I was thinking of was {}.'.format(number))
28 changes: 14 additions & 14 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ What do I mean by dynamic? Well, with a dynamically typed language you can do th
```sh
>>> variable = 1
>>> type(variable)
<type 'int'>
<class 'int'>
>>> variable = "Foo"
>>> type(variable)
<type 'str'>
<class 'str'>
>>> variable = ["bar",10]
>>> type(variable)
<type 'list'>
<class 'list'>
```

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.
Expand Down Expand Up @@ -191,7 +191,7 @@ Ruby has a bigger web presence with Rails than Python does with Django, so if yo
That said, take a look at the two code snippets below -

```python
print "Hello, World!"
print("Hello, World!")
```

and
Expand Down Expand Up @@ -242,34 +242,34 @@ Guessing game ...

```python
import random
import os


number = random.randint(1, 20)
guesses = 0

print 'Hello! What is your name?'
name = raw_input()
print('Hello! What is your name?')
name = input()

print "Hi, {}. I'm thinking of a number from 1 and 20.".format(name)
print("Hi, {}. I'm thinking of a number from 1 and 20.".format(name))

while guesses < 6:

print 'What is your guess. You have {} more guesses.'.format(6-guesses)
guess = raw_input()
print('What is your guess. You have {} more guesses.'.format(6-guesses))
guess = input()
guess = int(guess)

guesses = guesses + 1

if guess < number:
print 'Too low.'
print('Too low.')
elif guess > number:
print 'Too high.'
print('Too high.')
elif guess == number:
print 'Good job, {}! You guessed my number in {} guesses!'.format(name,guesses)
print('Good job, {}! You guessed my number in {} guesses!'.format(name,guesses))
break

if guess != number:
print 'Nope. The number I was thinking of was {}.'.format(number)
print('Nope. The number I was thinking of was {}.'.format(number))
```

#### Ruby
Expand Down