Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > [perl-python] 20050114 if statement

Reply
Thread Tools

[perl-python] 20050114 if statement

 
 
Xah Lee
Guest
Posts: n/a
 
      01-15-2005
.. # here's an example of if statement in python.
..
.. x=-1
.. if x<0:
.. print 'neg'
.. elif x==0:
.. print 'zero'
.. elif x==1:
.. print 'one'
.. else:
.. print 'other'
..
.. # the elif can be omitted.
.. ------------------------------
.. # here's an example of if statement in perl
..
.. $x=31;
.. if ($x<0) {
.. print 'neg'
.. } elsif ($x==0) {
.. print 'zero'
.. } elsif ($x==1) {
.. print 'one'
.. } else {
.. print 'other'
.. }
..
..
.. ---------------------------
..
.. Note: this post is from the Perl-Python a-day mailing list at
.. http://groups.yahoo.com/group/perl-python/
.. to subscribe, send an email to http://www.velocityreviews.com/forums/(E-Mail Removed)
.. if you are reading it on a web page, program examples may not run
.. because html conversion often breaks the code.
..
.. Xah
.. (E-Mail Removed)
.. http://xahlee.org/PageTwo_dir/more.html

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if statement that, when false, skips first statement in its block, executes second? Jay McGavren Java 11 01-16-2006 05:49 PM
How do I do a conditional statement in a constant statement? tkvhdl@gmail.com VHDL 3 12-16-2005 06:13 PM
[perl-python] 20050114 if statement Xah Lee Python 1 01-15-2005 07:39 AM
exec "statement" VS. exec "statement in globals(), locals() Ted Python 1 07-22-2004 08:51 AM
exec "statement" VS. exec "statement" in globals(), locals() tedsuzman Python 2 07-21-2004 08:41 PM



Advertisments