bumsfeld 413 Nearly a Posting Virtuoso

Write a Python program that displays this result:

1 * 8 + 1 = 9
12 * 8 + 2 = 98
123 * 8 + 3 = 987
1234 * 8 + 4 = 9876
12345 * 8 + 5 = 98765
123456 * 8 + 6 = 987654
1234567 * 8 + 7 = 9876543
12345678 * 8 + 8 = 98765432
123456789 * 8 + 9 = 987654321

vegaseat commented: neat +13
bumsfeld 413 Nearly a Posting Virtuoso

Up and down numbers:

111111111 * 111111111 = 12345678987654321

bumsfeld 413 Nearly a Posting Virtuoso

Wit this:

import math

print(math.cos((2*math.pi)/3))         # -0.5
print(0.5 + math.cos((2*math.pi)/3))   # 2.22044604925e-16
print(-0.5 + math.cos((2*math.pi)/3))  # -1.0

x = math.cos((2*math.pi)/3)
print(x)        # -0.5
print([x])      # [-0.4999999999999998]
print([-0.5 + x])   # [-0.9999999999999998]

Strange?

bumsfeld 413 Nearly a Posting Virtuoso

Comment:
If it wouldn't be for the huge amount of secret police in Saudi Arabia, they would quickly follow the example of Egypt.

In the US more children (under ten years old) get killed by swimming pools than guns. Actually, the chances of a child being killed by a swimming pool is 100 times higher than being killed by a gun.

bumsfeld 413 Nearly a Posting Virtuoso

You could add screen as one more argument to function question(q, a, b, c, d, screen).

bumsfeld 413 Nearly a Posting Virtuoso

Here is one short example how this sort of thing might be done:

# copy files with given file extensions from source to destination
# shutil.copy2() retains the last access time and modification time
# use shutil.move(src, dst) to move the file 

import os
import shutil

# assume you have created these destination folders
# you can use os.mkdir("C:/zz_zip") one time for instance
zip_folder = "C:/zz_zip"
pic_folder = "C:/zz_pic"
exe_folder = "C:/zz_exe"

# assume this is your download folder
download_folder = "C:/zz_download"

# loop through each file in the download folder
for fname in os.listdir(download_folder):
    # lower() takes care of any extension with upper case
    if fname.lower().endswith(".jpg"):
        source_file = os.path.join(download_folder, fname)
        destination_file = os.path.join(pic_folder, fname)
        shutil.copy2(source_file, destination_file)
    elif fname.lower().endswith(".zip"):
        source_file = os.path.join(download_folder, fname)
        destination_file = os.path.join(zip_folder, fname)
        shutil.copy2(source_file, destination_file)
    elif fname.lower().endswith(".exe"):
        source_file = os.path.join(download_folder, fname)
        destination_file = os.path.join(exe_folder, fname)
        shutil.copy2(source_file, destination_file)
    
    #print source_file, destination_file  # test

Nice project, but not easy by any means. If you experiment with the code, you can see how to shorten it some. Perhaps with some function to take care of repetitive code lines. One good exercise for you.

bumsfeld 413 Nearly a Posting Virtuoso
bumsfeld 413 Nearly a Posting Virtuoso

Make sure all your () match.

bumsfeld 413 Nearly a Posting Virtuoso
bumsfeld 413 Nearly a Posting Virtuoso

I found another way:

d = dict(enumerate('abcd'))
print(d)  # {0: 'a', 1: 'b', 2: 'c', 3: 'd'}
TrustyTony commented: usefull usage +3
bumsfeld 413 Nearly a Posting Virtuoso

Pythia, commonly known as the Oracle of Delphi, was the priestess at the Temple of Apollo at Delphi. Her site was on the slopes of Mount Parnassus in Greece.

bumsfeld 413 Nearly a Posting Virtuoso

Two eggs, thick sliced bacon and Hawaiian coffee.

bumsfeld 413 Nearly a Posting Virtuoso

Honk if your horn is broken

bumsfeld 413 Nearly a Posting Virtuoso

It is my understanding the xpath is more for XML document searches.

bumsfeld 413 Nearly a Posting Virtuoso

The median pay of professional American football players is about $800,000 per season.
The San Francisco 49ers have the highest median pay at $1,177,280 and the St. Louis Rams
the lowest at $537,990 (2010 regular season).

Source: http://content.usatoday.com/sportsdata/football/nfl/salaries/team

bumsfeld 413 Nearly a Posting Virtuoso

I used to be snow white, but I drifted!

bumsfeld 413 Nearly a Posting Virtuoso

Medium rare flank steak and grilled eggplant. Ah, the joy of cooking your own stuff!

bumsfeld 413 Nearly a Posting Virtuoso

TV in the US is full of Ghost Hunting shows where one bunch of nimrods walk around in dimly lit places equipped with night vision stuff and ghost meters. After all, about 60% of the American public believes in ghosts!

bumsfeld 413 Nearly a Posting Virtuoso

Chicken wings and corn chips

bumsfeld 413 Nearly a Posting Virtuoso

The 45th annual edition of the Super Bowl in American football will be played on Sunday February 6, 2011, at the Cowboys Stadium in Arlington, Texas. It will pit the AFC champion Pittsburgh Steelers against the NFC champion Green Bay Packers to decide the NFL champion for the 2010 season.

Get lots of beer and junk food so you can enjoy the game properly in front of the largest TV screen possible with your best friends.

I like the Green Bay Packers, just my personnel feelings.

vegaseat commented: love green bay +0
bumsfeld 413 Nearly a Posting Virtuoso

This review of the roomba and neato show that the neato is much more efficient with its planned path:
http://www.botjunkie.com/2010/06/04/irobot-roomba-560-vs-neato-xv-11/

bumsfeld 413 Nearly a Posting Virtuoso

Install spellchecker into your Python text processing program using modules like pyenchant from:
http://pypi.python.org/packages/any/p/pyenchant/

bumsfeld 413 Nearly a Posting Virtuoso

Want to do some spell checking using Python?
Here is one way:

# download pyenchant-1.6.5.win32.exe from
# http://pypi.python.org/packages/any/p/pyenchant/
# then install for Python31 (my case) or Python27
# see http://www.rfk.id.au/software/pyenchant/tutorial.html
# check a text against 2 different enchant dictionaries

from enchant.checker import SpellChecker

# use the US/English dictionary
chkr = SpellChecker("en_US")
text = "This is sme sample txt with erors."
chkr.set_text(text)
for err in chkr:
    print( "ERROR: %s" % err.word )

'''
ERROR: sme
ERROR: txt
ERROR: erors
'''

# try the German dictionary
chkr = SpellChecker("de_DE")
text = "Ein Deutscher Satz mid einigen fehlern."
chkr.set_text(text)
for err in chkr:
    print( "Error (German): %s" % err.word )

'''
Error (German): mid
Error (German): fehlern
'''

This gives you the available dictionary languages:

import enchant

# check default dictionary
d = enchant.Dict()
print(d.tag)  # en_US

# show available languages
print(enchant.list_languages())
'''
['de_DE', 'en_AU', 'en_GB', 'en_US', 'fr_FR']
'''
Gribouillis commented: Nice links +5
Lardmeister commented: great stuff +6
bumsfeld 413 Nearly a Posting Virtuoso

People from the future will think that television is what we made convicted criminals watch.

bumsfeld 413 Nearly a Posting Virtuoso

To list ammonia as some horrible chemical only shows the sorry educational state this country's news reporters are in.

bumsfeld 413 Nearly a Posting Virtuoso

An ugly carpet lasts forever.

bumsfeld 413 Nearly a Posting Virtuoso

When your only tool is OOP everything becomes objectionable.

bumsfeld 413 Nearly a Posting Virtuoso

Morality deals with the ideal world.
Economy deals with the real world.

bumsfeld 413 Nearly a Posting Virtuoso

The ten most popular names for females in the US as of 2010
1. Isabella
2. Emma
3. Olivia
4. Sophia
5. Ava
6. Emily
7. Madison
8. Abigail
9. Chloe
10. Mia

to be complete

The ten most popular names for males in the US as of 2010

1. Jacob
2. Ethan
3. Michael
4. Alexander
5. William
6. Joshua
7. Daniel
8. Jayden
9. Noah
10. Anthony

bumsfeld 413 Nearly a Posting Virtuoso

The average human body, consisting of about 10,000,000,000,000 cells, and has about ten times that number of microorganisms (mostly bacteria) in the gut.

bumsfeld 413 Nearly a Posting Virtuoso

And many new ones have cell phones pre-installed and ready to go any time day or night.

Are you talking about wife or girlfriend?

bumsfeld 413 Nearly a Posting Virtuoso

I prefer a trace of ammonia over Escherichia coli, urine, pubic hairs and cigarette butts.

bumsfeld 413 Nearly a Posting Virtuoso

Nice steak and white asparagus

bumsfeld 413 Nearly a Posting Virtuoso

Just curious how you got started.
For me it was science class that used Python as the main tool.

vegaseat commented: great idea +13
bumsfeld 413 Nearly a Posting Virtuoso

Are you running the 64bit Python version?

bumsfeld 413 Nearly a Posting Virtuoso

I don't like l as variable name (looks too much like number one), so I changed it a little:

import os
import fnmatch


for fn in os.listdir("C:/Bilder"):
    print fn  # test
    if fnmatch.fnmatch(fn, 'IMG*'):
        fn = fn.replace(fn, "HH")
        print fn

"""my result -->
IMG100_0015.jpg
HH
"""
bumsfeld 413 Nearly a Posting Virtuoso

Here is typical example of the PyQt QTabWidget() tested with Python27 and PyQT4.8.2

# explore the PyQt QTabWidget()

from PyQt4.QtCore import *
from PyQt4.QtGui import *

class MainWindow(QWidget): 
    def __init__(self): 
        QWidget.__init__(self) 
        # setGeometry(x_pos, y_pos, width, height) 
        self.setGeometry(250, 150, 400, 300) 
        self.setWindowTitle("explore QTabWidget()")         
         
        tab_widget = QTabWidget() 
        tab1 = QWidget() 
        tab2 = QWidget() 
         
        tab_widget.addTab(tab1, "page1") 
        tab_widget.addTab(tab2, "page2")
        
        # put a button on tab1 (page1)
        btn_hello1 = QPushButton("Hello page1", tab1)
        btn_hello1.move(10, 10)
        # put a button on tab2 (page2)
        btn_hello2 = QPushButton("Hello page2", tab2)
        btn_hello2.move(10, 10)

        # layout manager
        vbox = QVBoxLayout()
        vbox.addWidget(tab_widget)         
        self.setLayout(vbox)      

        # optionally create layout for each page
        p1_vbox = QVBoxLayout(tab1)
        #p1_vbox.addWidget(btn_hello1) 
        p2_vbox = QVBoxLayout(tab2)
        
        
app = QApplication([]) 
frame = MainWindow() 
frame.show() 
app.exec_()
bumsfeld 413 Nearly a Posting Virtuoso

Rocks several miles in diameter fly by the Earth as close as 100,000 miles away several times a week. Most of them are not detected until they are way past the Earth.

bumsfeld 413 Nearly a Posting Virtuoso

I recall the time when they showed the way chicken were slaughtered in schools. Many children stopped eating chicken meat that would have been good for their growth and health, and started eating Wonder Bread and hot dogs instead.

bumsfeld 413 Nearly a Posting Virtuoso

Romanesco and chicken

bumsfeld 413 Nearly a Posting Virtuoso

Face it, meat resources are dwindling with the ever increasing population.

bumsfeld 413 Nearly a Posting Virtuoso

"Everyone is entitled to his own opinion, but not his own facts!"
---- Daniel Patrick Moynihan

bumsfeld 413 Nearly a Posting Virtuoso

I am glad that our sun is as small at it is or it would have burned out long ago! In the universe small is okay! After all, the singularity that was at the origin of the big bang was so small it couldn't be measured.

bumsfeld 413 Nearly a Posting Virtuoso

Roasted chicken with green beans, mint tea.

bumsfeld 413 Nearly a Posting Virtuoso
bumsfeld 413 Nearly a Posting Virtuoso

Actually simpler:

# Tkinter, show the button that has been clicked
# using lambda

from Tkinter import *

class App:

    def __init__(self, master):

        frame = Frame(master)
        frame.pack()

        cmd1 = lambda: self.opt_def(1)
        self.opt1 = Button(frame, text="Opt1", command=cmd1)
        self.opt1.pack(side=TOP)

        cmd2 = lambda: self.opt_def(2)
        self.opt2 = Button(frame, text="Opt2", command=cmd2)
        self.opt2.pack(side=BOTTOM)

    def opt_def(self, opt):
        print 'You have choosen option', opt


root = Tk()

app = App(root)

root.mainloop()
bumsfeld 413 Nearly a Posting Virtuoso

Another way is to use the event:

# Tkinter, show the button that has been clicked
# using the bind event

import Tkinter as tk

def click(event):
    """
    event.widget.cget("text") gets the label
    of the button clicked
    """
    s = "clicked: " + event.widget.cget("text")
    root.title(s)

root = tk.Tk()
root.geometry("300x50+30+30")

b1 = tk.Button(root, text="button1")
b1.bind("<Button-1>", click)
b1.pack()

b2 = tk.Button(root, text="button2")
b2.bind("<Button-1>", click)
b2.pack()

root.mainloop()
bumsfeld 413 Nearly a Posting Virtuoso

Procrastination is like a credit card, fun until you get the bill.

bumsfeld 413 Nearly a Posting Virtuoso

If you know a good project, please post it here. If you have questions, start your own thread and don't clutter the sticky.

bumsfeld 413 Nearly a Posting Virtuoso

Some chocolate walnut brownies