User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 397,786 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,383 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 13650 | Replies: 3
Reply
Join Date: Aug 2006
Posts: 1
Reputation: pato is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
pato pato is offline Offline
Newbie Poster

Frequently Used Python Commands

  #1  
Aug 24th, 2006
Hey, I'm new to Python, as well as this message board, and I was wondering what some of the most useful and frequently-used commands are. I've so far only learned while, if, print, input # and words, and can make some basic programs only.

I've previously had experience in TI83 programming, so I know the basics. What are the commands for random integers, repeats, different text styles, etc?

EDIT: As long as I'm at it, does anyone know any good sites where I can easily check out scripts and the like?
Last edited by pato : Aug 24th, 2006 at 7:22 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 1,020
Reputation: Ene Uran is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 64
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Veteran Poster

Re: Frequently Used Python Commands

  #2  
Aug 25th, 2006
To find experiments with the Python random module see:
http://www.daniweb.com/code/snippet306.html

For loops and function range() are covered in:
http://www.daniweb.com/code/snippet386.html

You can search the Python snippets and this forum for other things like lists, strings, dictionaries, tuples, file handling and so on.

Different text types are the realm of GUI programming with Tkinter for instance.
Here is an example of a Tkinter GUI program that sets a text font and uses random:
# display random sentences from a list using colorful Tkinter

from Tkinter import *
import random

black  = '#000000'
blue   = '#0000FF'
red    = '#FF0000'
yellow = '#FFFF00'
lime   = '#00FF00'

sentenceList = [
'the dog is on skates', 
'the bird is on a plane', 
'the pig rides the horse',
'the snake is on rollerskates',
'the fish drives a car']

def setText():
    str1 = random.choice(sentenceList)
    push1.config(text=str1)
    

#create the form
form1 = Tk()

# set the form's title
form1.title('Random Text')

# create a button
push1 = Button(form1, text='Click to set new text .............', command=setText)

# configure the button's text font and foreground/background colors
push1.config(height=3, font=('times', 20, 'bold'), fg=black, bg=yellow)

# pack the button into the frame
push1.pack(expand=YES, fill=BOTH)

# start the event loop (run the program)
form1.mainloop()

A good tutorial for beginners is in this online book:
http://www.ibiblio.org/g2swap/byteofpython/read/
Last edited by Ene Uran : Aug 25th, 2006 at 12:17 pm.
drink her pretty
Reply With Quote  
Join Date: Jul 2005
Location: France
Posts: 980
Reputation: bumsfeld is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 43
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Posting Shark

Re: Frequently Used Python Commands

  #3  
Aug 26th, 2006
Richard Gruet has very good quick-reference of Python on his home page:
http://rgruet.free.fr/

The reference can be downloaded as HTML, zipped HTML or PDF file. It is in English.
Last edited by bumsfeld : Aug 26th, 2006 at 1:31 pm.
Reply With Quote  
Join Date: Aug 2005
Location: England - York
Posts: 136
Reputation: a1eio is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 9
a1eio's Avatar
a1eio a1eio is offline Offline
Junior Poster

Re: Frequently Used Python Commands

  #4  
Aug 26th, 2006
http://bembry.org/technology/python/index.php

Has a whole quick tutorial and it has notes on all the main topics it covers, so you can read it, or use it as a reference, i found the Tkinter section wickedly useful as a starter into gui stuff, it also has some exercises.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Python Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 5:17 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC