Post Reply 
What Was Your First Programming Language?
07-09-2015, 06:42 AM
Post: #92
RE: What Was Your First Programming Language?
(07-09-2015 01:55 AM)Sylvain Cote Wrote:  
Code:
print "Too high!" if ($guess > $number);
print "Too low!" if ($guess < $number);

Or then using the ternary operator ?:
Code:
print $guess > $number ? "Too high!" : "Too low!";

(07-09-2015 02:00 AM)Les Bell Wrote:  
Code:
        if guess > number :
            print("Too high! ");
        if guess < number :
            print("Too low! ");

Or then:
Code:
        print("Too high! " if guess > number else "Too low! ")

Cheers
Thomas

PS: In Python there's no need to put a semicolon at the end of each line.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: What Was Your First Programming Language? - Thomas Klemm - 07-09-2015 06:42 AM



User(s) browsing this thread: 2 Guest(s)