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 / 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 / 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
@horstjens
horstjens / 01_operatoren.py
Last active January 4, 2016 15:59
python3 Schulung
100 + 1
100 – 1
100 / 7
100 / 7.0
100 % 7
100 * 4
100 ** 2
100 ** 0.5
(100+1) * 2
100 + 1 * 2
@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 / turtlecannon1.py
Last active July 11, 2016 09:01
turtle cannonball
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()
@horstjens
horstjens / zahlenschloss2.c
Last active June 4, 2018 15:03
zahlenschloss
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int z = 0;
int level;
/* int gen();
int spiel(); */
@horstjens
horstjens / description.txt
Created March 3, 2015 17:35
turtle_example_leon.py
python3 example to play with turtle graphic