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

Appearance settings
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
45 changes: 45 additions & 0 deletions 45 Dragon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import random
import time

def displayIntro():
print('You are in a land full of dragons. In front of you,')
print('you see two caves. In one cave, the dragon is friendly')
print('and will share his treasure with you. The other dragon')
print('is greedy and hungry, and will eat you on sight.')
print()

def chooseCave():
cave =''
while cave != '1' and cave != '2':
print('Which cave will you go into? (1 or 2)')
cave = input()

return cave

def checkCave(chosenCave):
print('You approach the cave...')
time.sleep(2)
print('It is dark and spooky...')
time.sleep(2)
print('A large dragon jumps out in front of you! He opens his jaws and...')
print()
time.sleep(2)

friendlyCave = random.randint(1, 2)

if chosenCave == str(friendlyCave):
print('Gives you his treasure!')
else:
print('Gobbles you down in one bite!')

playAgain = 'yes'
while playAgain == 'yes' or playAgain == 'y':
displayIntro()

caveNumber = chooseCave()

checkCave(caveNumber)

print('Do you want to play again? (yes or no)')
playAgain = input()

18 changes: 18 additions & 0 deletions 18 DrawCircle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import math
import turtle

# draw the circle using turtle
def drawCircleTurtle(x, y, r):
# move to the start of circle
turtle.up()
turtle.setpos(x + r, y)
turtle.down()

# draw the circle
for i in range(0, 365, 5):
a = math.radians(i)
turtle.setpos(x + r*math.cos(a), y + r*math.sin(a))

drawCircleTurtle(100, 100, 50)
turtle.mainloop()

36 changes: 36 additions & 0 deletions 36 GuesstheNumber.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is a guess the number game.
import random

guessesTaken = 0

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

number = random.randint(1,20)
print('Well, ' + myName + ', I am thinking of a number between 1 and 20.')

while guessesTaken < 6:
print('Take a guess.')
guess = input()
guess = int(guess)

guessesTaken = guessesTaken + 1

if guess < number:
print('Your guess is too low.')

if guess > number:
print('Your guess is too high.')

if guess == number:
break

if guess == number:
guessesTaken = str(guessesTaken)
print('Good job, ' + myName + '! You guessed my number in ' + guessesTaken + ' guesses!')

if guess != number:
number = str(number)
print('Nope. The number I was thinking of was ' + number)


5 changes: 5 additions & 0 deletions 5 HelloWorld(GamingBook).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This program says hello and asks for my name.
print('Hello world!')
print('What is your name?')
myName = input()
print('It is good to meet you, ' +myName)
22 changes: 22 additions & 0 deletions 22 Jokes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import time

print('Ready for some jokes? Press "Enter" to continue.')
input()
print('What do you get when you cross a snowman with a vampire?')
input()
print('Frostbite!')
print()
time.sleep(1)
print('What do dentists call an astronaut\'s cavity?')
input()
print('A black hole!')
print()
time.sleep(1)
print('Knock, knock.')
input()
print("Who's there?")
input()
print('Interrupting cow.')
input()
print('Interrupting cow wh', end='')
print('-MOO!')
26 changes: 26 additions & 0 deletions 26 Spiro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# a class that draws a Spirograph
class Spiro:

# constructor
def _init_(self, xc, yc, col, R, r, l):

# create the turtle object
self.t = turtle.Turtle()
# set the cursor shape
self.t.shape('turtle')
# set the step in degrees
self.step = 5
# set the drawing complete flag
self.drawingComplete = False

# set the parameters
self.setparams(xc, yc, col, R, r, l)

# initialize the drawing
self.restart()

# set the parameters
def setparams(self, xc, yc, col, R, l):
# the Spirograph parameters
self.xc = xc
self.yc = yc
Morty Proxy This is a proxified and sanitized view of the page, visit original site.