Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
teaching python/pygame to children

Horst JENS horstjens

💭
teaching python/pygame to children
View GitHub Profile
@horstjens
horstjens / moreseeker.py
Created Nov 24, 2012
searching strings in files with python 3.2
View moreseeker.py
# 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 / organigramm.py
Created Jan 9, 2013
Algo Dat Übung 6 "Organigramm" python3 code
View organigramm.py
# 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
quiz for dennis with functions, while loops and an for loop ( iterating over a list of questions )
View dennisquiz.py
# 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.
View 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
View 01_operatoren.py
100 + 1
1001
100 / 7
100 / 7.0
100 % 7
100 * 4
100 ** 2
100 ** 0.5
(100+1) * 2
100 + 1 * 2
View goblindice001.py
"""
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
"""
View storyPrinter.py
# 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 / turtlecannon1.py
Last active Jul 11, 2016
turtle cannonball
View turtlecannon1.py
import math
import turtle as t
p1 = t.Turtle()
p1.left(70)
p1.speed=9
p1.dx = math.cos(p1.heading()*math.pi/180)*p1.speed
p1.dy = math.sin(p1.heading()*math.pi/180)*p1.speed
for step in range(100):
x = p1.xcor()
y = p1.ycor()
View zahlenschloss2.c
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int z = 0;
int level;
/* int gen();
int spiel(); */
@horstjens
horstjens / description.txt
Created Mar 3, 2015
turtle_example_leon.py
View description.txt
python3 example to play with turtle graphic