|
Next Meeting: Sat, TBD
Meeting Directions
|
Navigation:
20 Most Recent Documents
Search Archives
Index by date,
title,
author,
category.
|
|
Features:
Mr. Know-It-All
Ink
Download!
|
|
|
|
|
|
|
SCOUG:
Home
Email Lists
SIGs (Internet, General Interest, Programming, Network, more..)
Online Chats
Business
Past Presentations
Credits
Submissions
Contact SCOUG
Copyright SCOUG
|
|
Pictures from Sept. 1999
|
|
The views expressed in articles on this site are those of their authors.
|
SCOUG was there!
|
|
Copyright 1998-2024, Southern California OS/2 User Group.
ALL RIGHTS RESERVED.
SCOUG, Warp Expo West, and Warpfest are trademarks of the
Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of
International Business Machines Corporation.
All other trademarks remain the property of their respective owners.
The Southern California OS/2 User Group
USA
|
|
|
REXX vs. Python Examples
For use with the presentation of
REXX and Python Side-by-Side.
Example type |
REXX |
Python |
Block |
if <condition> then
do
Stmt 1
Stmt 2
if <another condition>
then
do
Stmt 21
Stmt 22
end
Stmt 3
end
Stmt 4 |
if <condition> :
Stmt 1
Stmt 2
if <another condition>:
Stmt 21
Stmt 22
Stmt 3
Stmt 4
|
Looping |
count = 1
do while count < 100
count = count + count
end
count = 1
do until count >= 100
count = count + count
end
do 3
say "Again"
end
pull HowMany
do HowMany
say "Again"
end
do i = 1 to 9 by 3
say "i is" i
end |
count = 1
while count < 100 :
count = count + count
while 1 == 1:
print "Help, I'm stuck in a loop."
for number in range(1,100):
print "Hello, world!"
print "Just", 100 - number, "more to go..."
print "Hello, world"
print "That was the last one... Phew!"
Note: The function range returns a list of
numbers in the range given (including the first, excluding the
last... In this case, [1..99]).
for food in "spam", "eggs", "tomatoes":
print "I love", food
This means: For every element in the list
"spam", "eggs", "tomatoes", print that you
love it. The block inside the loop is executed
once for every element, and each time, the
current element is assigned to the variable
food (in this case). |
Control |
number = <some random number>
guess = number + 1
do while guess \= number
say "Guess a number: "
pull guess
if guess > number then
say "Too high"
else if guess < number then
say "Too low"
end
say "Just right" |
number = <some random number>
guess = number + 1
while guess != number :
guess = input ("Guess a number: ")
if guess > number :
print "Too high"
elif guess < number :
print "Too low"
print "Just right" |
String
Operations |
-
string slicer
-
x = rexx
-
substr(x,2,2) returns: xx
-
substr(x,1,1) returns: r
|
-
string slicer
-
x = 'Python'
-
print x[0] prints: P
-
print x[2] prints: t
-
print x[-1] prints: n
-
print x[2:4] prints: th
-
|
Special
Variables |
|
|
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA
Copyright 2001 the Southern California OS/2 User Group. ALL RIGHTS
RESERVED.
SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
|
|