sneekula 969 Nearly a Posting Maven

Image manipulations to get art.

sneekula 969 Nearly a Posting Maven

I like avatars that say something about the owner.

sneekula 969 Nearly a Posting Maven

Vpython is good for 3D and plotting, but the slider is more than rude!

sneekula 969 Nearly a Posting Maven

The nice thing about standards is that there are so many to choose from.

sneekula 969 Nearly a Posting Maven

... this is your favorite pickup line:
"Hey sweets, does this rag smell like chloroform? "

skilly commented: 1 bad apple... +0
TrustyTony commented: Interesting one. +0
sneekula 969 Nearly a Posting Maven

"unzip; strip; touch; finger; mount; fsck; more; yes; unmount; sleep" - my daily unix commands

sneekula 969 Nearly a Posting Maven

A college physics professor was explaining a particularly complicated concept to his class when a pre-med student interrupted him.

"Why do we have to learn this stuff?" one young man blurted out.

"To save lives," the professor responded before continuing the lecture.

A few minutes later the student spoke up again. "So how does physics save lives?"

"Physics saves lives," he said, "because it keeps the idiots out of medical school."

sneekula 969 Nearly a Posting Maven

Porky Pig

sneekula 969 Nearly a Posting Maven

"Borrow money from a pessimist - they don’t expect it back."
~~~ E. Fudd

sneekula 969 Nearly a Posting Maven

Very strong coffee with cream.

sneekula 969 Nearly a Posting Maven

The new drink:
Osama, two shots and a splash of water

sneekula 969 Nearly a Posting Maven

Sailing on Lake Michigan, cool and crisp with a minimum of floating plastic bags!

sneekula 969 Nearly a Posting Maven

There are even people addicted to second hand smoke! Little kids in particular.

sneekula 969 Nearly a Posting Maven

Diced peaches on vanilla pudding, yum!

sneekula 969 Nearly a Posting Maven

XML data stream starts with an opening tag '<'
more elaborately '<?xml'

sneekula 969 Nearly a Posting Maven

"The Man With The Golden Gun" starring Roger Moore as James Bond (007).

I like most of the 007 movies. James Bond is my hero!

sneekula 969 Nearly a Posting Maven

This Tkinter example moves a ball (circle) in a horizontal line, but you can change that to a vertical line:

# a Tkinter moving ball that wraps around

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

root = tk.Tk()
root.title("Tkinter Moving Ball")

w = 420
h = 300
cv = tk.Canvas(root, width=w, height=h, bg='black')
cv.pack()

# create 50x50 square box for the circle boundries
box = (0, 120, 50, 170)
# create the ball object
# give it a tag name for reference
cv.create_oval(box, fill="red", tag='red_ball')

# endless animation loop till window corner x is clicked
x = 0
# set x, y increments
dx = 1
dy = 0
while True:
    # move the ball by given increments
    cv.move('red_ball', dx, dy)
    # 15 millisecond delay
    # higher value --> slower animation
    cv.after(15)
    cv.update()
    # when left side of ball hits wall reset
    x += dx
    if x >= w:
        print(x) # test
        cv.move('red_ball', -x, dy)
        x = 0


root.mainloop()

Should give you enough of a hint.

sneekula 969 Nearly a Posting Maven

Using those Tkinter tags:

# which widget has been clicked?

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

def clicked(event):
    """display the clicked oval's name"""
    # 'current' matches the item under the mouse pointer
    root.title( widget_list[cv.find_withtag('current')[0]-1] )


root = tk.Tk()
root.title('Click on ovals')

cv = tk.Canvas()
cv.pack()

oval1 = cv.create_oval(10, 30, 40, 50, fill='red', tags='click')
oval2 = cv.create_oval(50, 70, 80, 90, fill='blue', tags='click')
oval3 = cv.create_oval(90, 110, 120, 130, fill='green', tags='click')

# in order of creation
widget_list = ['oval1', 'oval2', 'oval3']

# left mouse click = '<1>'
cv.tag_bind('click', '<1>', clicked)

root.mainloop()

Not sure if this is new?

vegaseat commented: different approach +15
sneekula 969 Nearly a Posting Maven

Tired of turtles? Here some clever German educators have added advanced options to the venerable Tkinter turtle module:

# frog is a somewhat advanced turtle graphics module
# get frog-1.0.1.zip from:
# http://www.zahlenfreund.de/python/frog.html
# see also:
# http://pypi.python.org/pypi/frog/1.0.0
# unzip and copy frog.py into the Python lib/site-packages folder
# or use it in the working folder
# to make frog.py work on Python32 change line 51 to
# from PIL import ImageGrab

import frog

def draw_square(side=50):
    """
    kermit draws a square
    starts at the center of the pond
    """
    for n in range(4):
        kermit.move(side)
        kermit.turn(90)

def draw_triangle(side=50):
    """
    kermit draws a square
    """
    for n in range(3):
        kermit.move(side)
        kermit.turn(120)

# pond forms the canvas
pond = frog.Pool(width = 400, height = 400)
pond.title = "Watch Kermit move and draw"
pond.bgcolor = "lightblue"
# kermit forms the drawing pen
kermit = frog.Frog(pond)
kermit.shape = "frog"
kermit.bodycolor = "green"

draw_square(100)
# turn kermit 160 degrees
kermit.turn(180)
draw_square(100)

kermit.turn(90)
draw_triangle(100)

kermit.turn(180)
draw_triangle(100)

try:
    # use a wave sound file you have
    kermit.sing("boing.wav")
except:
    print("no soundfile")

s = "Kermit has moved a total of %0.1f pixels" % kermit.way
pen = frog.Frog(pond, visible=False)
pen.jumpto(-170, 140)
pen.color = "red"
pen.font = "Arial",8,"bold"
pen.write(s)

pond.ready()

A revisit.

sneekula 969 Nearly a Posting Maven

The 19th hole on the golf course is the bar in the club house!

sneekula 969 Nearly a Posting Maven

The Python module pygame is a GUI for games, animated or otherwise. Here is some simple animated drawing code:

# exploring the Python module pygame
# pygame free from: http://www.pygame.org/
# or: http://www.lfd.uci.edu/~gohlke/pythonlibs/
# bubble circles up the screen

import pygame as pg
import random

def draw(screen, background, width, height):
    # create a few random values
    x = random.randint(10, width)
    y = random.randint(100, height)
    radius = random.randint(20, 50)
    # random (r, g, b) color, avoid black (0, 0, 0)
    r = random.randint(20, 255)
    g = random.randint(20, 255)
    b = random.randint(20, 255)
    # bubble up until circle center (x, y) reaches top
    while y > 0:
        background.fill(pg.color.Color('black'))
        # draw.circle(Surface, color, pos, radius, width)
        # width of 0 (default) fills the circle
        pg.draw.circle(background, (r, g, b), (x, y), radius, 3)
        y -= 1
        # put the circle on the screen
        screen.blit(background, (0, 0))
        # update the screen
        pg.display.flip()

def main():
    pg.init()
    # create the pg window, give it a caption and bg color
    width = 680
    height = 460
    screen = pg.display.set_mode((width, height))
    pg.display.set_caption(' random bubbles')
    background = pg.Surface(screen.get_size())
    background.fill(pg.color.Color('black'))
    clock = pg.time.Clock()
    # the pg event loop ...
    while True:
        # quit when window corner x is clicked
        # there is a small delay
        for event in pg.event.get():
            if event.type == pg.QUIT:
                raise SystemExit
        draw(screen, background, width, height)
        # use a frame rate of 30 to avoid flickering
        clock.tick(30)

if __name__ == "__main__":
    main()
vegaseat commented: nice example +14
sneekula 969 Nearly a Posting Maven

The Python module pygame is a GUI for games. In this case we use OOP. Let's look at some simple drawing code:

# exploring the Python module pygame
# pygame free from: http://www.pygame.org/
# or: http://www.lfd.uci.edu/~gohlke/pythonlibs/
# use pygame sprites group to fill a screen with colorful shapes

import pygame as pg
import random

class Square(pg.sprite.Sprite):
    """
    create a square sprite with a random position and given color
    also needs screen (via pg.display.set_mode)
    """
    def __init__(self, screen, color):
        pg.sprite.Sprite.__init__(self)  # this will be self
        # the square
        self.image = pg.Surface((50, 50))
        self.image.fill(color)
        # random position
        self.rect = self.image.get_rect()
        self.rect.centerx = random.randrange(0, screen.get_width())
        self.rect.centery = random.randrange(0, screen.get_height())


def test():
    """testing the class Square"""
    pg.init()
    # create the pg window, give it a caption and bg color
    screen = pg.display.set_mode((640, 480))
    pg.display.set_caption(" colorful squares all over")
    background = pg.Surface(screen.get_size())
    background.fill(pg.color.Color('white'))
    screen.blit(background, (0, 0))

    # create a list of colored square sprite objects
    squares = []
    # go through the pg.color.THECOLORS dictionary of color names
    for color_name in sorted(pg.color.THECOLORS):
        print(color_name)  # test
        squares.append(Square(screen, pg.color.Color(color_name)))
    # pack all your sprites into a group container
    all_sprites = pg.sprite.Group(squares)

    # the pg event loop ...
    while True:
        for event in pg.event.get():
            # quit when window corner x is clicked
            if event.type == pg.QUIT:
                raise SystemExit
        # draw and show the group of sprites
        all_sprites.draw(screen)
        pg.display.flip()

# allows class Square to be a module
if __name__ == "__main__":
    test()
sneekula 969 Nearly a Posting Maven

I remember reading the story about a fellow who sold bagels on the honor system in the coffee rooms of a corporate office building in Washington DC. The building had their top managers on the upper floor and 'worker bees' on the lower floor. He discovered that the folks on the top floor were the least honest.

sneekula 969 Nearly a Posting Maven

Crazy Horse the great leader and warrior of the Teton Sioux.

sneekula 969 Nearly a Posting Maven

All your friends are dying out.

sneekula 969 Nearly a Posting Maven

Yes it does and what does it looks like?

A gold cylinder with smooth edges and four large pods attached, about the size of Costa Rica.

sneekula 969 Nearly a Posting Maven

Grilled scallops and asparagus with a glass of fine Italian wine.

sneekula 969 Nearly a Posting Maven

In war, truth is the first casualty.
-- Aeschylus (Greek dramatist 525 BC - 456 BC)

sneekula 969 Nearly a Posting Maven

I was dreaming about a UFO. Does that count?

sneekula 969 Nearly a Posting Maven

Liver dumplings and Weizen Beer

sneekula 969 Nearly a Posting Maven

Working people always finance the rich folks gala events.

debasisdas commented: agree agree agree..... +0
sneekula 969 Nearly a Posting Maven

I am active on another forum, but always come back to DW.

sneekula 969 Nearly a Posting Maven

The slight error that BP committed in the Gulf of BP brings to mind the speculation that there are massive pools of liquefied methane gas in the depth of the oceans. If released, they could deplete the Earth's atmosphere of much of it's oxygen.

sneekula 969 Nearly a Posting Maven

I would imagine that Dallas and Arlington Home Inspectors listen to the sound of all those Dollar bills the are cheating their unsuspecting customers out of.

Seriously, I find that classical music is best for any good programming language.

sneekula 969 Nearly a Posting Maven

Your code seems to work well, except your grade assignments are a little strange to me.

Here would be a slightly different approach to some of your code:

""" assume these are the contents of file student.txt
Fred, Nurke, 16, 17, 22
Jack, Sprat, 12, 13, 19
"""

# create a list of each student's
# [firstName, lastName, asg1Mark, asg2Mark, examMark] data list
studentList = []
for line in open("student.txt"):
    tempList = []
    for item in line.split(","):
        # strip leading spaces and trailing newline char
        item = item.strip()
        #print item  # test
        tempList.append(item)
        #print temp_list  # test
    studentList.append(tempList)

print studentList  # test

for student in studentList:
    firstName, lastName, asg1Mark, asg2Mark, examMark = student
    totalMarks = int(asg1Mark) + int(asg2Mark) + int(examMark)
    # test
    print "%s %s total mark = %d" % (firstName, lastName, totalMarks)
sneekula 969 Nearly a Posting Maven

So we have no private attribute as C++ in python.yes?
has python any thing about machine for hardware managmente or some thing like?
for example if we want to write a program that works on a set such as CNC or other sets such as this?

Yes, Python has private attributes, but it uses "name mangling" to implement it. For all practical purposes this is good enough!

sneekula 969 Nearly a Posting Maven

Looks like you need the following information:
customer name
shipping address
unique tracking number
item
number of items
cost per item
method of payment

Need to calculate:
total cost of all items
shipping cost
total to be paid

Has it been paid?
Has it been shipped?

sneekula 969 Nearly a Posting Maven

I would create a class Order
with the following methods:
new_order
update_order
show_orders

sneekula 969 Nearly a Posting Maven

how can I develop a program in PASCAL that counts the number of words in a paragraph

Pascal is a very old style language. I don't think it would come even close to Python's modern syntax and features.

You could try the Delphi/Python forum at DaniWeb.

The closest thing you could use to take advantage of modern language concepts is Python for Delphi:
http://mmm-experts.com/Products.aspx?ProductID=3

sneekula 969 Nearly a Posting Maven

Don't worry, Goldman has enough money to prevail in the political arena!

sneekula 969 Nearly a Posting Maven

A baked salmon/spinach patty on orzo pasta.

sneekula 969 Nearly a Posting Maven

You don't create a class by listing it's methods as variables!

sneekula 969 Nearly a Posting Maven

Ouch! You may want to read up on the basics and use a few test prints.

sneekula 969 Nearly a Posting Maven

MASH

sneekula 969 Nearly a Posting Maven

So, books do matter!

sneekula 969 Nearly a Posting Maven

Exercise your right to remain silent.
~~~ Theodor Tobler

sneekula 969 Nearly a Posting Maven

Free advice can cost plenty.
~~~ Jacques-Yves Cousteau

sneekula 969 Nearly a Posting Maven

F u cn rd ths u cnt spl wrth a dm!

sneekula 969 Nearly a Posting Maven

In the Netherlands many schools have adopted graves of Allied servicemen killed in action during WW2, keeping those graves in excellent condition.

sneekula 969 Nearly a Posting Maven

The Boston University Bridge is the only place in the world where a boat can sail under a train driving under a car driving under an airplane.