Skip to content

Instantly share code, notes, and snippets.

View horstjens's full-sized avatar
💭
teaching python/pygame to children

Horst JENS horstjens

💭
teaching python/pygame to children
View GitHub Profile
@horstjens
horstjens / goblindice001.py
Last active August 29, 2015 14:00
Goblin Dice
"""
Name: goblindice001.py
Purpose: combat sim of one goblin against a test dummy
edit code: https://gist.github.com/horstjens/11267180#file-goblindice001-py
edit website: https://github.com/horstjens/ThePythonGameBook/tree/gh-pages
main project: http://ThePythonGameBook.com
Author: Horst JENS, horst.jens@spielend-programmieren.at
Licence: gpl, see http://www.gnu.org/licenses/gpl.html
"""
@horstjens
horstjens / storyPrinter.py
Created July 29, 2014 06:22
story printer
# pyhton3 example to teach python coding to young students
import random
friends = ["Anne","Bettina","Clara","Daniela"]
verbs = ["kissing","beating", "taunting","scaring","cooking","cleaning","eating","feeding"]
things = ["frog","airplane","castle","wizard","spaceship","elephant"]
adjectives = ["growing","impatient","hungry","angry","happy","sad", "unruly","nervous"]
@horstjens
horstjens / description.txt
Created March 3, 2015 17:35
turtle_example_leon.py
python3 example to play with turtle graphic
@horstjens
horstjens / moreseeker.py
Created November 24, 2012 21:39
searching strings in files with python 3.2
# to test this , create a file called poem.txt in the same folder as this python file
# make sure there are a lot of "more" in the poem.txt like
poem = """there is more to the world
than Demi Moore and Roger Mooore
It is a good Morning, but more so
a good day to every moron out there,
gimme more, more, moreofit"""
# i assume you are using python3.2 here
# open file as fileoobject f
@horstjens
horstjens / caesarchiffre1.py
Last active November 10, 2015 07:37
caesars chiffre 1
# Caesar Cipher
# from Al Sweigarts invent with python book https://inventwithpython.com/chapter14.html
MAX_KEY_SIZE = 26
def getMode():
while True:
print('Do you wish to encrypt or decrypt a message?')
mode = input().lower()
if mode in 'encrypt e decrypt d'.split():
import random
# legende: # Fels . Boden T Troll ! trap
dungeon = """
###############################################
#......................bbb.....#.....#........#
#.............................................#
#.............................................#
###############################################
"""
@horstjens
horstjens / fantasynames.py
Last active November 24, 2015 09:36
fantasy name generator from Crhistoph, a bit improved
#Fantasynamengenerator (python3)
"""generates fantasy names"""
def namensgenerator(namen):
"""im docstring in triple-quotes beschreibt man was die funktion tut"""
namensliste = []
output = ""
while len(namensliste) < anzahl:
neuername = (random.choice(namen[0]))+(random.choice(namen[1]))
if neuername not in namensliste:
@horstjens
horstjens / organigramm.py
Created January 9, 2013 11:53
Algo Dat Übung 6 "Organigramm" python3 code
# Struktur der Firma: { Name: ( Name erster Unterling, Name nächster Kollege), .. }
# oder: [ (Name, Name erster Unterling, Namer nächster Kollege), .. ]
firma = { "A":("B","-"), "B":("-","C"), "C":("E","D"), "D":("G","-"),
"E":("-","F"), "F":("-","-"), "G":("-","-") }
# Problem in 2 Teilprobleme zerlegen. 1.) wie viele direkte Untergebene
# hat Mitarbeiter m ?
def mitarbeiterzaehler(m):
@horstjens
horstjens / dennisquiz.py
Created May 4, 2013 18:31
quiz for dennis with functions, while loops and an for loop ( iterating over a list of questions )
# python3
# hi dennis. first, let us define parts that repeat themself a lot
# programmers hate typing the same thing over and over and prefer
#to define (def) function and call them over and over ... it's less typing
# let's define a function that simply prints the different possibilitys for the user
# ask the user for an answer, checks the answer (ask again if answer was invalid)
# and return the correct answer. (0,1,2 or 3). Note that those answers are strings.
@horstjens
horstjens / hangman
Last active December 20, 2015 00:19 — forked from yipyip/hangman
#!/usr/bin/env python3.3
# -*- coding: utf-8 -*-
"""A Hangman Demo for Python3 form yipyip. Guess some python3 keywords !
see https://gist.github.com/yipyip/6038584 for original code
"""
####
import random