This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def play(): | |
true_value = str(random.randint(1000, 9999)) | |
guesses = 0 | |
play = 'y' | |
while play == 'y': | |
cows = 0 | |
bulls = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def draw_board(): | |
n = int(raw_input("Enter the board size you want: ")) | |
if n == 1: | |
print(" ---") | |
print("| |") | |
print(" ---") | |
else: | |
for i in range(n): | |
print(""), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def birthday_lookup(): | |
birthdays = {"Albert Einstein": "14/03/1879", \ | |
"Benjamin Franklin": "17/01/1706", "Ada Lovelace": "10/12/1815"} | |
print("Welcome to the birthday dictionary. We know the birthdays of: \ | |
\nAlbert Einstein\nBenjamin Franklin\nAda Lovelace") | |
look_up = raw_input("Who's birthday do you want to look up? ") | |
print("%s's birthday is %s.") %(look_up, birthdays.get(look_up, "there is no such person in our dictionary")) | |
check_birthday = "y" | |
while check_birthday == "y": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numbers = [70, 55, 100.5] | |
def max_(numbers): | |
greatest = numbers[0] | |
for x in numbers: | |
if x > greatest: | |
greatest = x | |
print(greatest) | |
max_(numbers) |
OlderNewer