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?

Recommended Answers

All 4 Replies

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/

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.

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.

umm i know a few thieng for begginers like

print('WORDS GO HERE')

or if u want it to wait on somethieng u can do

import time
time.sleep(TIME TO SLEEP LIKE 10)

IN TIME TO SLEEP WRIGHT THE AMOUT OF SECCONDS TO WAIT FOR

**hope this helps****

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.